Presentation is loading. Please wait.

Presentation is loading. Please wait.

Eclipse.

Similar presentations


Presentation on theme: "Eclipse."— Presentation transcript:

1 Eclipse

2 1. Introduction to eclipse
Extensible software development framework based on a plug-in architecture. open source, released under a common public license (CPL). Originally developed by IBM, version 1.0 being released in November 2001 Now under the stewardship of an independent consortium including: IBM, SAP, Sybase, Fujitsu, HP, BEA…

3 Eclipse architecture “UI” “Core” JDT PDE Platform Runtime
Eclipse Platform Workspace Workbench SWT JFace Team Help Debug Ant “Core” “UI”

4 Eclipse Architecture explained
Platform runtime Primary job is to discover the available plug-ins. Each plug-in has an XML manifest file which lists the connections the plug-in requires. The workspace Manages the user's resources which are organized into projects. The workspace maintains a history of changes to resources. The workbench Eclipse's Graphical User Interface, menus, toolbars and perspectives. Perspectives provide a GUI for specific areas of functionality such as debugging, plug-in development,... The Standard Widget Toolkit (SWT) are graphics toolkits which map directly to the OS native graphics. JFace is a toolkit built on SWT.

5 Eclipse Architecture explained
Team Support Version control. Eclipse provides a client for Concurrent Version System (CVS) Help An extensible help component Java Development Toolkit (JDT) Toolkit for the writing and debugging of Java programs. Plug-in Development Environment (PDE) Developing plug-ins for extending ECLIPSE.

6 Workspace Component Tools operate on files in user’s workspace
Workspace holds 1 or more top-level projects Java project package class field method Java editor

7 Workbench Component Workbench is UI personality of Eclipse Platform
UI paradigm centered around Editors Views Perspectives Perspectives are arrangements of views and editors Different perspectives suited for different user tasks Users can quickly switch between perspectives Example: java perspective, debug perspective, resource perspective…

8 Workbench Component Perspective Switcher Editor Views

9 2. Eclipse Installation Web Site:

10 Eclipse Installation

11 Eclipse Installation No installer, just unzip it and create a shortcut for eclipse.exe Be sure to install Java first before installing eclipse

12 Eclipse Installation

13 3. Running Eclipse Click Or type eclipse after the prompt.

14 Running Eclipse Choose a workspace (a directory used by Eclipse to store your programs) When you first start Eclipse, Eclipse will ask you to specify the workspace to use.  Accept the default workspace provided by Eclipse or specify an existing directory as the workspace.  Example: 자바강의/dev

15 Running Eclipse Go to the workbench

16 Running Eclipse Java perspective ( an interface for editing java source code) Debug Perspective (an interface for debugging the program)

17 Load an Existing Java Program
1. Open Folder and find the Workspace directory you use for Eclipse. 2. Create a folder named PrintSquares (or any other name you prefer) under the workspace directory. 3. Download PrintSquares.java to PrintSquares folder you just created.

18 In Eclipse create a project named PrintSquares.
Click New Java Project button. Type PrintSquares as the project name and then click Finish button.

19 4. In Workspace window double click PrintSquares, then (default package), and then PrintSqaures.java. The source code of PrintSquares.java is shown in Edit window.

20 Compile the program If Build Automatically is checked, the program will be automatically compiled whenever you save the program.

21 1. Modify “PrintSquares.java” source code as follows:
2. The red marks on the left side of Edit window indicate that there are errors in PrintSquares.java. Move the cursor over a red mark to see the error message. int i; Change to //int i; Modify the code Red marks

22 3. Click Save button on the toolbar to compile the program
3. Click Save button on the toolbar to compile the program. Problems window shows the errors in the source code. Double click an error message and the cursor in Edit window will automatically move to the line in the source code where the error appears. Cursor move to here Problems window Double click the error message

23 4. Correct PrintSquares.java source code as follows:
5. Click Save button to compile the code again. //int i; Change back to int i; Error has been corrected No errors

24 Run the program Right click PrintSquare.java in Workspace window and select Run As> Java Application. 2. Console window shows the outputs of the program. Console window Outputs of the program

25 Debug a Program 1. Add breakpoints: double-click the gray bar on the left of Edit window. A blue dot indicates a breakpoint. To remove a break point, double click the breakpoint. A break point

26 2. Select Run->Debug as...->Java Application to start the debugger.

27 3. Click Yes button in Confirm Perspective Switch window to switch Eclipse from Java Perspective to Debug Perspective. Toolbar for debug Edit window

28 4. Play with the debug commands and watch the change of variable values in Variable window and the outputs in Console window. Resume resume the execution of a paused program. Suspend temporarily pause the execution of a program. Terminate end the current debug session. Step Into execute a single statement or step into a method. Step Over execute a single statement. If the statement contains a call to a method, the entire method is executed without stepping into the method. Step Return execute all the statements in the current method and returns to its caller. Run to Line runs the program, starting from the current execution point, and pauses places the execution point on the line of code containing the curor, or at at a breakpoint.

29 5. Switch Eclipse from Debug Perspective back to Java Perspective.

30 4. Some useful features BankAccount Class

31 Changing Comments Select Window > Preferences, then in dialog box select Java > Code Style > Code Templates > New Java Files > Edit

32 Generates Getters/Setters
Select Source > Generate Getters/Setters

33 Generates Getters/Setters

34 Generate Constructor Using Fields

35 Generate Constructor Using Fields

36 Generate Constructors from Superclass

37 Generate Constructors from Superclass

38 5. Create a New Java Application Example: create a HelloWorld java application
1. Create a new project named HelloWorld. First click New Java Project button. Then in New Java Project window input the project name as HelloWorld and click Finish button.

39 Create a New Java Application
2. Click New Java Class button to create a Java class. In New Java Class window, input HelloWorld as the name and check the box "public static void main (String[] args)" if you want a main method. 3. Modify HelloWorld.java source code as follows Add System.out.println(“Hello World”); inside Main method 4. Follow the instructions in the previous slides to compile and run the HelloWorld program.

40 Closer Look at Hello World Program
// HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public static void main(String args[]) System.out.println(“Hello World”); }

41 Closer Look at Hello World Program
// HelloWorld.java: Hello World program import java.lang.*; class HelloWorld { public static void main(String args[]) System.out.println(“Hello World”); } /* helloworld.c: Hello World program */ #define <stdio.h> void main(int argc, char *argv[]) { printf(“Hello World\n”); } Java C The .java file name must be the same as the name of class with main method

42 main method The class has one method – main()
public static void main(String args[]) { System.out.println(“Hello World”); } Command line input arguments are passed in the String array args[] e.g java HelloWorld John Jane args[0]: John args[1]: Jane

43 import import java.lang.*;
Java allows grouping of related classes into a package. It allows different companies can develop different packages, may even have same class and method names, but they differ by package name: ibm.mathlib.* microsoft.mathlib.* Helps in managing name clash problems. Think of this package as library. “import” statement somewhat serves similar purpose as C’s #include If you don’t add import statement, then you need utilise fully qualified name. ibm.mathlib.sin() If you do “import ibm.*” then you can use mathlib.sin() instead.

44 import Java imports java.lang.* by default
So, You don't need to import java.lang.* That means, you can invoke services of java’s “lang” package classes/entities, you don’t need to use fully qualified names. We used System.out.println() instead of java.lang. System.out.println()

45 public static void main(String args[])
public: The keyword “public” is an access specifier that declares the main method as unprotected. static: It says this method belongs to the entire class and NOT a part of any objects of class. The main must always be declared static since the interpreter uses this before any objects are created. void: The type modifier that states that main does not return any value.

46 System.out.println(“Hello World”);
java.lang.* All classes/items in “lang” package of java package. System is really the java.lang.System class. This class has a public static field called out which is an instance of the java.io.PrintStream class. So when we write System.out.println(), we are really invoking the println() method of the “out” field of the java.lang.System class.


Download ppt "Eclipse."

Similar presentations


Ads by Google