Eclipse Getting Started

xiaoxiao2021-03-06  116

Author: Lee Kun This article taken from: open systems world - SEOUL

At present, various integrated development environments (IDE) in the Java Development Field (IDE) presents a hundred flowers, from Borland's JBuilder, to IBM's Visual Age for Java, WebSphere Studio, Oracle's JDeveloper, Sun's Forte for Java, Visual Cafe, WebGain, TOGETHERSOFT TOGETHER, there is also an open source Eclipse, NetBeans, etc., and 10 kinds of kinds. Such a variety of IDEs have prospered Java development tools, but also puts a problem for the selection of developers. The development environment of these IDEs has a large difference, and the projects developed in a development environment cannot be easily ported to another development environment, which requires more careful development tools for project objectives. In all IdEs, Eclipse can be said to be one of the most developed products. Eclipse was originally created by the IDE product development group of OTI and IBM, starting from April 1999. IBM provides the initial Eclipse code foundation, including Platform, JDT, and PDE. Currently by IBM, surrounding the Eclipse project has developed into a huge Eclipse alliance, more than 150 software companies involved in the Eclipse project, including Borland, Rational Software, Red Hat and Sybase, recent Oracle also plans to join Eclipse Among the leagues.

basic concepts

Before learning to use Eclipse, it is necessary to explain some nouns on this project. Eclipse is an open source software development project that provides a full-featured, commercially available industrial platform for highly integrated tool development. It consists of three projects of Eclipse project, Eclipse tool project, and Eclipse technology projects, and each project is supervised by a project management committee and manages it by its project. Each project consists of its own subproject and uses the COMMON PUBLIC LICENSE (CPL) version 1.0 license agreement. The Eclipse Tools project provides a focus to different tool builders to ensure that the best tools are created for Eclipse Platform. The Task of the Eclipse Tools project is to create a wide range of tools for Eclipse Platform. Tool projects provide a single contact point to make an open source tool constructor, making override and repetition, minimizing sharing, and the creation of shared components, promoting seamless interoperability of different types of tools. Tools Projects are proposed by the Tool Developer Commission and Tools Projects, subtitles, chosen and developed sub-projects. The task of the Eclipse Technical Project is to provide new pipelines for open source developers, researchers, colleges and educators to participate in the evolution of Eclipse in the future. It organizes three projects in research, cultivation and education, and research projects explore and study in Eclipse related areas such as programming languages, tools and development environment; cultivating projects are small, unsuccessful structured projects, for Eclipse software Foundation add new ability; education project focuses on the development, teaching help and courseware of education materials. Eclipse Platform is an open scalable IDE. Eclipse Platform provides a basis for building blocks and construction and running integrated software development tools. Eclipse Platform allows tool builders to develop a seamlessly integrated tool for tool builders. You don't have to distinguish between a tool function, and another tool function starts. Eclipse SDK (Software Developer Package) is a sub-project (Platform, JDT, PDE) produced by 3 Eclipse projects, which can be downloaded once. These parts provide a development environment with rich features that allow developers to effectively build tools that can be seamlessly integrated into Eclipse Platform. The Eclipse SDK is combined by the tools produced by the Eclipse project and a third-party software from other open source code. The software produced by the Eclipse project is published in CPL, and third-party components have their own license agreement. Download, install Eclipse

Know these information about the Eclipse project, we can download, install an Eclipse. Eclipse SDK is what we want to download, including all the contents of the development of Java applications and all the results of the Eclipse project. Enter the homepage of the Eclipse project http://www.eclipse.org, click on Downloads to enter the download page. The latest version of Eclipse is version 2.0.2, but the multi-language translation package of version 2.0.2 has not yet come out, so we can use a little bit of version 2.0.1. Click 2.0.1 to enter its download page, this page has a lot of download connections, including Eclipse SDK in many platforms, here we only need to download Eclipse-sdk-2.0.1-Win32.zip and NLS-SDK-2.0.1 -Translations.zip two files can be, and there is an eclipse-examples-2.0.1-win32.zip file, which is required to learn the Java Development User Guide. Unzip these three files to the same directory, such as D: / Eclipse. You should first install JDK (Sun's JDK or IBM JDK before running Eclipse, you should install 1.3 or later version, recommended to use 1.4 or higher version, because only JDK using 1.4 or later can enjoy the new HotSwap function The convenience of debugging), set a good environment variable Java_Home, ClassPath, and Path. Eclipse.exe under D: / Eclipse creates a shortcut on the desktop. Double click to start Eclipse. Eclipse can also start in a command line, specify the JVM and save data on the command line, for example: D: /Eclipse/eclipse.exe-vmd: / WebSphere / AppserVMD: / WebSphere / Appserver / Java

/bin/javaw.exe -data

D: / Work / Workspace

Among them, D: / Work / Workspace is the location where the project file is saved. You can choose Help → Help Content Enter the Help System for Eclipse. With Eclipse's multi-language translation pack, all menu and online help have been translated into Chinese, which is very convenient to use. Before making the following learning, it is recommended to browse the "Workbed User Guide" in the help, familiar with the concept of perspective and view.

Write a Hello World program

Below we write a HellWorld program, steps below: 1. Select File → New → Item; 2. Project categories selection Java; 3. The project list selection Java project; 4. Click "Next"; 5. Enter the project name, for example: helloproject; 6. Click "Finish"; 7. Click "Create Java Class" in the tool bar (with a C mark) as shown in Figure 1;

Figure 1 Click "Creating a Java Class" button to call

8. Enter helloWorld; 9 in the name domain; Click on the PUBLIC Static Void Main (String [] args) check box to create the main method (see Figure 2);

Figure 2 Eclipse creates a main method

10. Click "Finish"; 11. A Java editing window will open, enter the system.out.println ("Hello World") line in the main method; 12. Use Ctrl-S to save, which will automatically compile helloWorld.java; 13. Click the "Run" button in the toolbar; 14. Select "Java Application" and select "New"; 15. Enter the project name Hello-Project and Main class name HelloWorld; 16. Click "Run"; 17. At this time, a console window will be opened, and a "Hello World" will be displayed (see Figure 3). Figure 3 "Hello World" Display Window

Eclipse has an incremental compiler that automatically compiles every time a Java file is saved. This feature is called "automatic build". If this feature is not required, you can perform automatic build on the window → preference → Workbench → to perform automatic build, turn off this feature. The "All Build" button will appear in the toolbar. Similar options will also appear in the relevant menu.

Create a CVS repository

Now we know how to create a project, the next step is to establish a connection with a version server, publish the project into the version server. At present, open source software uses CVS to make version management, so we also use CVS to exemplify. The Eclipse SDK has included a plug-in that supports CVS. To use other version management software, such as VSS, you can download related plugins from the Eclipse website. The steps to create a CVS repository location are as follows: 1. Open CVS Resource Library Development Perspective (Window → Open Perspective → Other → CVS Resource Library Development). 2. Right-click on the CVS repository view, create a new → repository location, see Figure 4.

Figure 4 New Resource Location

3. Enter the details of CVS Server in the Add CVS Resource Board dialog. 4. Click "Finish". 5. Once the CVS repository is configured, you can enter the project to enter the repository. Go to the Java perspective, right click on the project name, select the group → sharing item. 6. Select the repository that just added. 7. Click "Finish". 8. Right-click on the project in the synchronization window, choose the submission. 9. Enter a comment to submit to join, as shown in Figure 5.

Figure 5 is a submission to the comment

10. Click "OK", the project is released to the CVS repository.

11. After sharing projects in the resource library, you can use the "Synchronization" feature to "Synchronize" and caught up with someone else's modifications to the code in the resource library. Right-click on the project, group → synchronize with the repository.

Download, install application server JBoss

In order to do server-side development, you still need an application server and integrate the application server with Eclipse. Eclipse can work together with a variety of application servers, including WebLogic, WebSphere, Jrun, Orion / Oracle9ias, JBoss, Jonas, Resin, etc. The following is exemplified by the current popular open source application server JBoss. The first thing I want to download and install JBoss, I am using JBoss 3.0.3, installed in the D: /JBoss-3.0.3 directory. In order to integrate JBoss with Eclipse, you also need to download related plugins, download location is http://www.genuitec.com/products_easie.htm, http://www.genuitec.com/products/easiejboss1.0.6.zip. There is also a installation guide in http://www.genuitec.com/products/eclipse_jboss.pdf. Exit Eclipse, unzip the file just downloaded under D: / Eclipse, restart Eclipse. The newly installed plugin needs to be activated to use, select window → custom perspective, select the EASIE JBOSS item in "Other". Then configure this plugin, select Window → Preferences, and enter information about JBOSS plug-ins. After the above is performed, the button that starts and stops JBoss will appear in the toolbar. Click the Start button to start JBoss, as shown in Figure 6. Figure 6 Start JBoss

Open the debugging view, you will see the JBoss process related to the initiated JBoss process in the debug perspective. Stop JBoss can use the stop button next to the start button. On this website, there is also a plugin for WebLogic, WebSphere, Orion / Oracle 9ias, and the installation method is basically exactly the same.

Eclipse debugging

So far, the configuration required to establish a complete development environment is basically completed. Let's go back to the Hello World project, look at what you need to do. Those who have used IDE are very familiar with the concept of breakpoints, single-step operation, and Eclipse has debugging features that all IDEs should have. The debugging steps are as follows: 1. First set a breakpoint in the program, double-click the gray area on the left of the statement, then a breakpoint is added to the statement, as shown in Figure 7;

Figure 7 Set breakpoint

2. Click the debug button (a bug) in the toolbar; 3. Select HelloWorld; 4 under the Java application. Click "Debug" and the program will run to the breakpoint set up, then stop running; 5. Press F6, single step, and then the program runs to the next statement; 6. Press F8 to continue to run to the end of the program.

Import JUnit Example

Below we import a real project, this project comes from an example of Eclipse JDT. 1. Select file → import; 2. Select "ZIP file"; 3. Browse and find the location where the source code JAR file is located, enter junit; 4 in the folder; Click "Finish" to import a new JUnit project, as shown in Figure 8.

Figure 8 Import item

转载请注明原文地址:https://www.9cbs.com/read-124599.html

New Post(0)