[ZT] Eclipse Getting Started: User Guide

xiaoxiao2021-03-05  25

November 2001 IBM announced a donation of $ 40 million of Eclipse projects to open source. What is the favorite Eclipse? How to use it? The first part of this article will make you have a preliminary understanding of Eclipse. Also, Eclipse This name is how to develop the IDE set of language developed in the future, how will it achieve this grand target? The second part introduced the Eclipse plugin development will be the key. Eclipse is the next-generation IDE development environment that replaces IBM Visual Age for Java (hereinafter referred to as Ivj), but its future goal is not only a IDE environment specializing in developing Java programs, but it can expand according to the eclipse architecture, it can expand To any language, it can even be a tool drawn. Currently, Eclipse has begun to provide a function plugin for C language development. It's more difficult to expensive, Eclipse is an open source project, anyone can download the source code of Eclipse, and develop its own function plugin on this basis. That is to say, as long as someone needs it, there will be a development plugin that is built in languages ​​such as COBOL, Perl, Python, Eclipse. At the same time, you can extend the functionality of the existing plug-in by developing new plugins, such as adding Tomcat server plugins in an existing Java development environment. You can expand unlimited, and there is a unified look, operation, and system resource management, which is also the potential of Eclipse. Although the Eclipse project is currently not completed, it has been able to appreciate the Eclipse design leading ideology and the main features from existing versions. Learn now, Eclipse can not only make the majority of programmers to the idea of ​​high ideas, but more importantly, if they can participate in the development of the Eclipse project or read its open source, this for the majority of programmers It is undoubtedly a good opportunity to improve the programming level. Eclipse plans to provide versions of multiple platforms, like Windows, Linux, Solaris, HP-UX, and AIX, and below, only describe Windows versions. The first part of this article first introduces the basic use of Eclipse. The second part describes how to develop Eclipse's plugin. One. Eclipse Introduction Eclipse is an open source project, you can download the latest version of Eclipse for free from www.eclipse.org, general Eclipse offers several download versions: Release, Stable Build, Integration Build and Nightly Build, it is recommended to download Release or Stable. Version, the author is build20020125 (Stable version). The Eclipse itself is written in Java language, but the downloaded compressed package does not include Java running environments, requiring users to install JRE separately, and indicate the path to bin in the JRE in the environment variable of the operating system. The step of installing Eclipse is very simple: just decompress the downloaded compressed package according to the original path. Be careful If you have an updated version, you must first remove the old version to reinstall, you can't directly decompress the original path to cover the old version. After decompression, you can go to the corresponding installation path to run the Eclipse.exe. If downloaded the Release or Stable version, and the JRE environment is installed correctly. Generally, there will be no problem. After flashing a cool, Eclipse shows its default interface:

Figure one

At first glance, Eclipse's interface is a bit like JBilder, but it will find it more like IVJ in the actual operation process. After all, the leading amount of developing Eclipse is the development of IVJ's principal (can refer to www.oti.com). It is also worth mentioning that in addition to the IBM, there is a large number of people such as Borland, Rational Software, Redhat, Merant, etc., which laid a good foundation for Eclipse's future. The following will provide a brief introduction to the various characteristics of Eclipse, including: file storage, development environment, compilation and operation, version management, and plug-ins. 1. File storage Most IVJ's beginners are very uncomfortable for finding Java source code, because IVJ stores all source code into a Reposiotory library file, you want to get the source code for text format must be used from reponse from Report Guide the export code. Ivj used by ReponsTory almost extremely extremely extreme, which is this, making many programmers to love IVJ. Eclipse saves the source code in text, but implements almost all functions of IVJ on source code management, and adds some new features to achieve this, not sighing at the Eclipse developer's superb skills. After installing Eclipse, there will be a Workspace folder in the next layer of the installation path. Generate a new item in Eclipse, which will be generated in Workspace to store all files used in Workspace to store all files used in the project. You can use the Windows Explorer to access or maintain these files directly. There are three ways to add existing files to a project: The first is the same as in IVJ, import files into the project in the "IMPORT" function in the "File" menu. This is also recommended. The second is to drag files into the project directly from Windows Explorer. The third is to copy the file directly into the project folder, and then select the item or folder in the Eclipse's resource browsing window and perform the Refresh from locate. One point to be explained is that the project folder can be placed anywhere in the computer, and can specify the project path to the existing project folder in Eclipse, and then refresh in Eclipse. However, it should be noted that any project folder is established or specified, and it is currently only implemented in the Eclipse method, even if it is newly created under the Workspace path of the default storage project folder, in Eclipse It is also unable to turn it into a project, that is, this folder is not visible to Eclipse. 2. Like the Eclipse development environment, the Eclipse development environment is called Workbench, which is mainly composed of three parts: view (editor), edit window (Editor), and viewing window (View). In the following introduction, I hope the reader knows that the Java view, the Java package browsing window, the resource view, the resource browsing window (in fact, the most important thing is to distinguish the view and window) to avoid confusion in further reading. Figure 2 is the relationship structure between them: Figure 2

In Figure 2, you can see that Workbench contains multiple views, while each view also contains different windows. Since each editing window has a lot of commonality and the default, they are displayed in the same area, so we only marked a editing window in each view to represent green. Observing the window is different, here is expressed in red. Let's first introduce the editing window. The display and editing of all files are included in the edit window. By default, multiple files are arranged in the TagTable mode in the same window, which can be used to arrange these files into a variety of layouts. The method is to drag the label (tag) of a file to the border of the editing window, release when the cursor has the corresponding changes. When the file is added to the project, double-click the file in the resource browsing or java package, Eclipse will try to open this file: where the Eclipse embedded editor can open some files default, such as * .java, *. Txt, * .class, etc. If it is other type of file, Eclipse calls the operating system's corresponding default editor to open, such as Word documents, PDF files, etc. At the same time, Eclipse can also open the corresponding file with the specified editor like IVJ. For example, when you double-click the HTML file in the Eclipse project, you may want to open with notepad instead of using the system default IE. The implementation method is to open the WorkbenchàPReferences dialog box in the menu bar, then select WorkbenchàFile Editors in the dialog, then add file type, such as * .html, and specify the editor to it. In the editing window, it is worth noting that the programmer who is accustomed to editing the Java program when editing the Java program (ie, only a single method is displayed in the editing window, not the source of all the program. Code), this method is indeed very reasonable development method, not only the display of the code is more simple, and can assist the programmer to have a better package. The Eclipse provides a switch button on the toolbar that can be switched between "display all code" and "only the selected unit" (here the unit refers to a single method, variable, imported packet, etc.) The following figure 3). It is recommended that there is no programmer who uses IVJ, also try to develop code development in the "only displayed unit" state. Secondly, it is the observation window, which matches the editing window and provides a variety of related information and browsing methods. Commonly used observations include Resource Browse Window (Navigator), Java Packet Browse Window (Packages), Console, Tasklet (Task), and more. The browsing window and Java browsing window are part of the viewing window. The former and Windows browsers are similar, can browse all files in the project folder, the latter used to browse information in the Java package in the project, the variables and methods in the classes in the package, the variables and methods in the class. In the Java browsing window, you can open the hierarchical browsing window (Hierarchy) in the menu of the mouse button, this window is very practical, it can view the hierarchy of the class very clearly. Compiling error information in the class can be found in the task window, and it can also be a mission-active task window: add new task description information to track the progress of the project. The console is primarily used to display the output information of the program. In debugging, there will be a richer observation window to help programmers make debugging, such as variable values ​​to see windows, breakpoint windows, and more.

The observation window is the core of any IDE development environment. It is also a good IDE development environment using a good observation window. Eclipse offers a wealth of observation windows that can really use these windows. I am afraid to have been hone after a period of time. Last introduction view. A view includes one or more editing windows and viewing windows. The upper part of the leftmost shortcut bar in the development environment is displayed the currently open view icon. The view is the most flexible part of Eclipse, which can customize the type of observation window included in each view, or you can customize a new view. These features are included in the "Perspective" menu. Several default views are available in the Eclipse's Java development environment, such as resource perspective, the default view of the first time Eclipse), Java perspective, debug perspection, Team view (Team Perspective, etc.). Each view corresponds to different types of observation windows. You can see the viewing window corresponding to the view from the perspectiveàshow view in the menu bar. Of course, the observation window of each view is configurable, and you can configure in the Perspectiveàcustomize in the menu bar. Diversified views can not only help programmers observe the code in different angles, but also meet different program habits. 3. Compile and run in the IVJ debugging function is very powerful, multiple tracking methods, breakpoint settings, variable value checksions, etc. These are also available in Eclipse. When the plugin is introduced herein, it will be more detailed in connection with the example how to use the configuration project environment, how to run and debug programs. In the Java view, there are two buttons in the toolbar, which are used to debug and run separately. And maybe the plug-in of the installed plug-in will exist in a variety of run / debugprues, in order to determine the current item to run, you need to set the launcheràrun / debug option in the item's properties option. Usually we need to use the "Java Applicance" mode. In this manner, if the current location is a Java program containing the main () method, click the debug / run button to immediately start the debug / run function. If the current location is on the package or item, Eclipse searches all the executables included in the current location, and then selects the run by the programmer himself. The plug-in development environment is installed in the current Eclipse's Release and Stable versions (PLUG-IN Development Environment, PDE, which is also a plug-in), at which time the system is running in addition to "Java Applicance", there may be two Method: "Run-Time Workbench" and "Run-Time Workbench with Tracing", when using PDE development plug-ins, it will be used below, we also mention it. 4. Version management can divide Eclipse version management into two types of individuals (or). Eclipse provides a powerful personal version of management mechanism, each saved changes can be recovered. And you can recover from the version of each method.

The operation is also very convenient, in any of the observation window that you want to operate, such as the resource browsing window, select the file, click the right mouse button, select Compare with or replace with, if it is the method that has been deleted, you can Choose Add from local history, then the corresponding local history will appear, follow your needs to find the corresponding version. Powerful personal version management functions provide more confidence in programmers: only, any accidental mistake can be recovered, developing under Eclipse, there is "regret medicine"! Eclipse default provides an interface for version management tool CVS, which is very convenient to connect to the CVS server. With CVS version management, Eclipse provides a good environment for team development. To connect the CVS server, you need to open the team view (Team Perspective) and then click the right mouse button in the Repositalies Observatory and select New. In the open dialog box, you can fill in the information you need to connect to the CVS library you want, such as CVS server type, current Eclipse supports three ways: PServer, ExtSSH, and EXT, you have to fill in user name, host name, password, repounds, etc. information. Using CVS in Eclipse, it is necessary to pay attention to some terms and function changes. Branch in CVS is called stream, cancel the function of Check Out, Import, and Commit in CVS, and the TEAM-> synchronized in the right mole menu. With stream is replaced. These functions are done through the graphical interface. There will be current files and the comparison window of the previous versions in each operation, the operation is very intuitive, easy to master, so this will not be further introduced. 5. Use the plug-in to use the plugin to enrich the functionality of Eclipse. Here's how to apply plugins to embed Tomcat servers. This plugin is not developed by the Eclipse project group, but a company called Sysdeo, very small, only 27.8k. You can go to http://www.sysdeo.com/eclipse/tomcatplugin.html to free download. In addition, this plugin only supports version of Tomat 4.0, which can get the latest version of Tomcat at www.apache.org. To install a plugin, simply extract the downloaded ZIP files to "your Eclipse's installation path / plugins" below, then restart Eclipse. After startup, select Perspectiveàcustomize on the menu bar, select Otheràtomcat in the open dialog. It will immediately find that Eclipse has two changes: there is a Tomcat option in the menu bar. There are two buttons in the toolbar. The top is the Tomcat kitten that you might be familiar with, as shown below. In addition, in the menu bar selection: WorkbenchàPReferences, you will find that this also a Tomcat option is required to specify your Tomcat installation root path here. Then check if the JRE specified in the Preferences dialog box, the JRE specified by JavaàInStalled JRE, whether the Tomcat's JRE is the same jre, if not, may cause Tomat to start normally. If there is no problem with the above check, you can start Tomcat directly with "Kitten" on the toolbar. It should be noted that the startup process is slow, and it is patiently waiting until the following information appears:

Starting Service Tomcat-StandalongApache Tomcat / 4.0.1

Starting Service Tomcat-Apache

After Apache Tomcat / 4.0.1, you can enter http: // localhost: 8080 in an external browser (such as IE) to test whether Tomcat is normal.

Figure three

If it is normal, you can further try to debug the servlet or JSP program in Eclipse. Below we will use Tomcat's servlet routine HelloWorldexample.java to demonstrate how to debug the Sevlet program in Eclipse. First, you must create a new Java project in the Java view. For convenience, you can directly assign the project path to the path where the HelloWorldExMaple program is located, as shown in Figure 4:

Figure four

After pressing "Next", go to the Java Settings dialog, select the libraries tab, and use the Add External Jars button to specify the location of the servlet.jar package. It uses the servlet.jar package in Tomcat. Figure 5:

Figure 5

Finally, click "Finish" to complete the generation of the project. Default package in the new project can find HelloWorldexample.java, double-click Open file, and try to add a breakpoint to HelloWorldexample (double-click the Edit window left boundary). After the external browser, enter http: // localhost: 8080 / examples / servlet / helloWorldexample, then see what Eclipse changes, is a debug window! Debugging operations in Eclipse and the vast majority of identities are similar, such as setting breakpoints, single-step tracking, variable value, etc., it will not be detailed here.

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

New Post(0)