When you first open Eclipse, you first see the following welcome screen:
Figure 1. Eclipse Workbench
The Eclipse table consists of several panes called views (view), such as Navigator views in the upper left corner. The set of panes is called a perspective (PERSPECTIVE). The default perspective is a resource perspective, which is a basic generic view set, used to manage the project and the files in the project.
The Navigator view allows you to create, select, and delete items. The pane on the right side of Navigator is the editor area. Depending on the selected document type in Navigator, an appropriate editor window will open here. If Eclipse is not registered for an appropriate editor for a particular document type (for example, a .doc file on a Windows system), Eclipse will try to use an external editor to open the document.
Navigator The following Outline view displays the outline of the document in the editor; the accuracy of this outline depends on the type of editor and document; for the Java source file, the outline will display all declared classes, properties, and methods.
The Tasks view collects information about the item you are operating; this can be the information generated by Eclipse, such as compiling errors, or you can manually add tasks.
Most of the tables of the workbench, such as menus and toolbars, should be similar to those familiar applications. A convenient feature is a shortcut toolbar of different perspective, which is displayed on the left end of the screen; these features have significant differences in the following and history. Eclipse also comes with a robust help system, including the Eclipse workbench and user guide for plugins (such as Java Development Tools). At least it browsing this help system is worth it, which can see which available options, and better understand the workflow of Eclipse.
To continue this brief Eclipse tour, we will create a project in Navigator. Right click on the Navigator view and select New => Project. When the New Project dialog box appears, select the left Java. Standard Eclipse has only one Java project type called "Java Project". If the plugin is installed to provide JSP and Servlet support, we will see an additional option for web applications here. Now, select Java Project, enter "Hello" when prompted the project name, and press Finish.
Next, we will check the Java perspective. Depending on your favorite screen management method, you can change the perspective in the current window by selecting Window => Open Perspective => Java, or you can select Window => New Window, then select this new perspective, thus Open a new window.
As you may expect, the Java perspective contains a group of views that are more suitable for Java development. One of them is the view of the upper left corner, which is a hierarchy containing a variety of Java packages, classes, jar, and other files. This view is called Package Explorer. Pay attention to the main menu has been expanded - two new menu items appear: Source and Refactor.
Java Development Environment (JDE) is a Java development environment, we will create and run a "Hello, World" application. Use the Java perspective, right-click "Hello" item, select New => Class, as shown in Figure 2. In the subsequent dialog box, type "Hello" as class name. In "Which Method Stubs Would You Like To Create?", Select "Public Static Void Main (String [] args" check box, then press Finish. Figure 2. Creating a new class in the Java perspective
This will create a .java file that contains the Hello class and empty main () method in the editor area, as shown in Figure 3. The following code is then added to the method (note that the declaration of I is intended to be omitted):
Figure 3. Hello class in the Java editor
You will notice some of the features of the Eclipse editor when typing, including syntax checks and code auto-completion. In version 2.1 (I have downloaded M2 editions), when you type a knot or double quotation, Eclipse automatically provides paired symbols and places the cursor within the symbol.
In other cases, you can call the code automatic completion by pressing Ctrl-Space. The code automatically completes the list of suggested suggestions, you can choose from the list via the keyboard or mouse. These recommendations can be a list of methods for a particular object, or a code snippet that is expanded based on different keywords (such as for or while).
Grammatical check reliance on incremental compilation. Whenever you save the code, it accepts compilation and syntax check in the background. By default, syntax errors will be displayed in red underline, and a red dot with white "X" will appear on the left. Other errors indicate along the left side of the editor; these are the editor perhaps the problem that you can fix - the so-called Quick Fix feature.
The above code example has a bulb-like icon behind the for statement because the declaration of i is omitted. Double-click the icon to call up the recommended fix list. In this example, it will provide recommendations for creating a class field I, a local variable I or a method parameter i; one of the suggestions that click it will display the code to be generated. Figure 4 shows the recommended list and the code generated after a local variable is recommended.
Figure 4. Quick FIX suggestion
Double-click the suggestion to insert the suggestion code into the appropriate location in your code.
Once the code is not erroneously compiled, you can select RUN from the Eclipse menu (note that there is no separate compilation step because compile is done when you save the code. If the code does not have a syntax error, it Can run). A Launch Configurations dialog with an appropriate default setting will appear; please press the Run button in the upper right corner. A new tab pane will appear in the following pane (console), which shows the output of the program, as shown in Figure 5.
Figure 5. Output of the program
You can also run the program in the Java debugger. First double-click the gray edge of the left end of the editor view to set a breakpoint in the main () system.out.println () after calling System.out.Println (). A blue point will appear there. Then select Debug from the RUN menu. As described above, a Launch Configurations dialog appears. Please select RUN. The perspective will automatically switch to the Debug perspective, which has many interesting new views, as shown in Figure 6:
Figure 6. Debug Perspective First, note the DEBUG view of the upper left corner of this perspective. This view displays the stack, and there is a toolbar in the title bar, which allows you to perform execution, including continuing, suspend, or terminating programs, tracking the next statement, single-step execution, or returning from ways.
The pane in the upper right corner contains many tabs, including Variables, Breakpoints, Expressions, and Display. Here I click on the Variables view so that we can see the current value of I.
You can get more information about these views by context-sensitive help: click on the title, then press F1.
Additional plugins In addition to the plug-ins of JDT for editing, compiling, and debug applications, some available plugins support from modeling, generating automation, unit testing, performance test, and version control to configure management's complete development process.
The Eclipse standard comes with a plug-in with CVS, and CVS is an open source code for source code control and a Concurrent Version System. The Team plug-in is connected to the CVS server, allowing a member of the development team to operate a set of source code files, but will not cover each other changes. Here is not intended to further explore how to source source code from Eclipse, as this requires installation of CVS servers, but supports development teams, not just independent development, this is an important essential feature of Eclipse.
Some third party plugins that have been available or have announced include:
Version control and configuration management
CVS merant PVCS Rational ClearCase
UML modeling
Omondo Eclipseuml Rational Xde (instead Rose) TOGETHER WebSphere Studio Edition
Graphic
Batik Svg Macromedia Flash
Web development, HTML, XML
Macromedia Dreamweaver XMLBuddy
Application server integration
Sysdeo Tomcat Launcher
Example: A plugin for UML modeling
To view the plugin, and how to integrate with Eclipse, download popular Omondo Eclipseuml (http://www.eclipseuml.com/); you need to register, but the plugin is free. This plugin relies on GEF, which is Graphical Editor Framework, which is another Eclipse plugin. GEF is part of the Tools subproject. To download the GEF, go to the Eclipse Web site, select Downloads, and then click the "Tools PMC Downloads Page" link. Note that you need to download the GEF version recommended by Omondo (for Omondo 1.0.2 is a GEF version 2.0).
After downloading, the plugin installation is usually done by decompressing the download file and copy its content to the Eclipse plugin directory. In this example, the GEF needs to decompress the Eclipse directory (it will automatically enter the plugin directory from the directory). For security, you may want to extract it into a temporary directory, and then copy the relevant directory accordingly. If Eclipse is running, you will need to stop it and then restart it so that it can recognize the newly installed plugin.
Once Eclipseuml (and gef) installation is complete, you can create a class diagram like creating a Java class file. In the Java perspective, right-click the "Hello" project in Package Explorer and select New => Other from the pop-up menu. There will be a new option for UML in the left pane of the New dialog. The free version of Eclipseuml only supports a class diagram, so the only option on the right is UML Class Diagram. Please select UML Class Diagram and type a name for this class, such as "Hello": Figure 7. Class Diagram Editor
A graphic editor will appear in the editor area, which has a canvas for drawing a class diagram. You can create class diagrams in two ways: Drag and drop the Java file from the package Explorer to the existing code reverse engineering; or use a blank class map to draw a drawing tool in the toolbar. To test the first method, create a new class called Person (using file => new => class) and then given the two private properties listed below:
/ ** Person.java
* @Author David
* /
Public class person {
PRIVATE STRING NAME;
Private address address;
/ **
* Returns the address.
* @Return Address
* /
Public address getaddress () {
Return Address;
}
/ **
* Returns the name.
* @Return String
* /
Public string getname () {
Return Name;
}
/ **
* Sets the address.
* @Param Address The Address to set
* /
Public void setaddress (address address) {
THIS.ADDRESS = Address;
}
/ **
* Sets the name.
* @Param Name the name to set
* /
Public void setname (String name) {
THIS.NAME = Name;
}
}
Type only for Name and Address. Getter and setter methods are automatically generated by Eclipse, ie, right-click source code, and then select Source => Generate Getter and Setter from the pop-up menu. )
Please save and close Person.java Hello.ucd.
Figure 8. Person class diagram
To create a Java class from UML, click the "New Class" button on the top toolbar on the Class Cap window, you click on the third button, and then click the chart. When the New class wizard is opened, type adress as class name and press Finish.
You can first click on the class name and select New => Attribute to add attributes to the class. In the New Properties dialog box, enter the property name, type, and visibility. Then right-click the class name and select New => Method to add a method.
When you change the class map, the Source Editor window below will reflect the changes made. Finally, you can click on the Association button (fifth from left) to draw a line segment from the Person class to the Address class to draw the relationship diagram between the two classes. This will call another dialog that you can enter the associated property (see Eclipseuml Help for more content about the required information). The chart after completion should be similar to: Figure 9. Association
This UML plugin demonstrates several typical features of the Eclipse plugin. First, it shows the tight integration between the tools. The surface is absolutely unasight to see multiple components at work; integration with the Eclipse platform and JDT is seamless. For example, when the Person class is created, it shows a syntax error because it is not defined by ADDRESS. Once the Address class is created in the UML diagram, these components are displayed separately.
Another feature is the ability of Eclipseuml to utilize other plug-ins. - In this example, it is a GEF plugin that provides tools for developing visual editing editors.
Another feature involves the way the Eclipseuml plugin uses multi-level features. The basic plugins that support the class diagrams are free, but more mature versions will be available.