About Eclipse
Eclipse is an integrated development tool developed by IBM with a $40 million investment. It is currently one of the most popular Java integration development tools, written in the Java language, and is an open source, extensible (Integrated Development environment,ide) development tool. In addition, IBM donated the Eclipse source code and formed the Eclipse Alliance, which is responsible for the subsequent development of this tool. Eclipse provides programmers with a first-class Java programming development environment. Its platform architecture is built on the concept of plug-ins, which is one of the most characteristic features of the Eclipse platform and one of the characteristics that distinguishes it from other development tools. After studying this chapter, the reader will have a preliminary understanding of Eclipse, which lays the groundwork for the deep learning behind.
1. Perspective perspective is an additional organizational layer provided by the Eclipse Workbench, that is, a perspective view that acts as an organization that implements the layout of multiple views and a collection of available actions, and defines a name for the collection. For example, the Java perspective provided by Eclipse organizes a collection of views and actions related to Java programming, while the debug perspective is responsible for organizing the view and set of actions related to program debugging. Several common perspectives are available in the Java development environment of Eclipse, such as the Java perspective, the resources perspective, the debug perspective, the group synchronization perspective, and so on. You can switch between different perspectives, but only one perspective is used at the same time.
2. Views are used to browse the hierarchy of information and to display properties of the activity editor, for example, the console view is used to display output information and exception errors when the program is run, while the Package Explorer view can browse the file organization structure of the project. Views can appear individually, or they can be overlaid with other views with tab styles, which can have their own separate menus and toolbars, and can be dragged to change the layout position.
The Eclipse's menu bar contains basic eclipse commands, and the menu for that editor is added dynamically when using a different editor. The basic menu bar, in addition to the commonly used menus such as file, edit, window, and Help, provides a menu of features such as "Source code" and "refactoring", as shown in.
Menu bar
Each menu contains different commands that are used to complete the final operations, such as opening and saving files, code formatting, running programs, and stepping through debugging. Each menu contains commands as shown in.
Tool bar
The Eclipse's toolbar is located below the menu bar, which is the same layout format as most software. The buttons in the toolbar are shortcut icons for the menu commands, and new toolbar buttons related to the editor are added dynamically when you open different editors. In addition, in addition to the main toolbar below the menu bar, there are a variety of toolbars in eclipse, including the View toolbar, the Perspective toolbar, and the Quick View toolbar.
The Package Explorer View
The Package Explorer view is used to browse Java elements in the project structure, including packages, classes, class library references, and so on, but the main purpose is to manipulate the source code files in the project. The interface of the Package Explorer view is as shown.
The console view
The console view is used to display output and run-time exception information (runtime Exception) when the program is run. Before learning swing programming, you must use the console to interact with the program, for example, to facilitate debugging of a method, outputting both the "method start" and "Method end" information before and after method execution. The interface of the console view is as shown.
Create a Java Project
To write a program in Eclipse, you must first create the project. There are many kinds of projects in Eclipse, where Java projects are used to manage and write Java programs.
To create a Java class file
When you create a Java class file, the Java Editor opens automatically. Creating a Java class file can be done through the New Java Class Wizard. Selecting the File/New/class command in the Eclipse menu bar opens the New Java Class Wizard dialog box, as shown in.
Writing program code using the editor
The editor is always located in the middle of the Eclipse Workbench, where you can place multiple editors in overlapping areas. The types of editors can be different, but their primary function is to complete code writing or visual design work for Java programs, XML configurations, and so on.
Running Java programs
The Hellojava class contains the main () master method, which is a main class that can be run. For example, to run the Hellojava program in Eclipse, you can right-click the Hellojava file in the Package Explorer view and choose the Run AS/Java application command from the menu that pops up. The program runs as shown in the results.
Program debugging
Breakpoint
Setting breakpoints is an essential tool in program debugging, and the Java debugger suspends the current thread each time it encounters a program breakpoint, pausing the current program's run. You can display the location of the code line number in the Java Editor double-click to add or remove a breakpoint from the current line, or right-click the current line number and choose the Toggle Breakpoint command on the popup shortcut menu to add and remove breakpoints, as shown in.
Running Java programs in debug mode
To debug a Hellojava program in Eclipse, you can right-click the Hellojava file in the Package Explorer view and choose the debug mode/Java Application command from the shortcut menu that pops up. At the 8th line of code to set a breakpoint, the debugger suspends the current thread at that breakpoint, causing the program to pause as shown in.
Program debugging
After the program executes until the breakpoint is paused, you can perform the appropriate debugging actions, such as run, stop, and so on, through the buttons on the Debug View toolbar. The debug view is as shown.
Java-based development tools Eclipse usage