Introduction to Eclipse development tools

Source: Internet
Author: User

Eclipse is a Java-based, open-source, extensible application development platform that provides programmers with a first-class Java integrated development environment (Integrated development environment,ide). A Java EE version of the Eclipse IDE is available on the Eclipse's official website. Apply Eclipse IDE for Java EE, either to create a Java project or to create a dynamic Web project.

1.1 Understanding the Eclipse Workbench

Double-click the file in the Eclipse installation directory to start Eclipse, in the dialog box that pops up the Select workspace, specify the workspace location as shown in the workspace directory under the Eclipse installation directory, 2.1.

Figure 2.1 Setting up a working space

Note: each time you start Eclipse, a dialog box will pop up to set up the workspace, and if you want to stop working space settings at a later time, you can select the "Use this as the default and does not ask again" check box.

(2) Click the OK button and if you first enter the workspace that you selected in step (3), the Eclipse Welcome page appears, or you go directly to the eclipse's work station. If the Welcome screen appears, close the Welcome screen and go to Eclipse's main interface, the Eclipse's Workbench window. Eclipse's Workbench consists primarily of menu bars, toolbars, perspective toolbars, Perspectives, Project Explorer views, outline views, editors, and other views. The eclipse is shown in work table 2.2.

Figure 2.2 Eclipse's Workbench

1.2 Eclipse's Menu Introduction

The menu bar is available above the Eclipse Workbench, which contains commands for implementing Eclipse features and is related to the editor, where the menu item in the menu bar is associated with the file that is open in the current editor. For example, if no file is open in the editor, the menu bar shown in 2.2 will be displayed. If a JSP file is open, the menu bar shown in 2.3 is displayed.

Figure 2.3 Eclipse's Menu bar

As you can see from Figure 2.3, when you open a JSP file, the Eclipse menu bar includes 10 menus that contain the corresponding submenus. The common menu in Eclipse 2.4 is shown in.


1.3 Introduction to Shortcut keys

In the process of program development, reasonable use of shortcut keys can not only reduce the error rate of code, but also improve the development efficiency. Therefore, it is necessary to master some common shortcut keys. There are many shortcut keys available for this eclipse, which can be viewed in the following steps.

(1) In the Eclipse's System menu bar, select "Window" → "Preferences" menu item, as shown in 2.5.

Figure 2.5 Choosing the Preferences menu

(2) In the Preferences dialog box that opens, after you expand the General node, select the Keys child node for that node, and the dialog box shown in 2.6 appears.

Figure 2.6 Keys dialog box

(3) In the list to the right of Figure 2.6, the commands provided in Eclipse and their corresponding shortcut keys are displayed, where the reader can view the shortcut keys for the command you want, or you can select the specified command to modify the shortcut key for the command.

Note: Although you can modify the shortcut keys for Eclipse commands through the Keys dialog box, I do not recommend that you modify the shortcut keys for Eclipse.

(4) Eclipse common shortcut keys

Eclipse's editing capabilities are powerful, and mastering the editing-related shortcut keys can greatly improve the development efficiency. The common shortcut keys provided by Eclipse are shown in table 2.1.

Table 2.1 Common shortcut keys

Shortcut keys

Description

alt+/

Code hints

F3

Jump to the declaration of a class or variable

Alt + up and DOWN ARROW keys

Move the selected row or rows up or down

Alt + left and RIGHT arrow keys

Jumps to the previous or last edit position, with more code tracking

Ctrl +/

Commenting or canceling comments

Ctrl + D

Delete the code for the line where the cursor is located

Ctrl + K

Hover the cursor over the variable and press Ctrl+k to find the next same variable

Ctrl + O

Open a small window of a view

Ctrl + W

Close a single Window

Ctrl + mouse click

Can track the source code of methods and classes

Ctrl + mouse Stay

can display the source code of methods and classes

Ctrl + M

Maximizes the current view

Ctrl + L

The cursor rests on a variable, and pressing the CTRL+L key provides a quick-to-implement refactoring method. Select several rows and press Ctrl+l to place the code into a block of code such as For,while,if,do or try

Ctrl + Q

Back to the last edit position

Ctrl + F6

Toggle Window

Ctrl + shift+k

In the opposite direction of the Ctrl+k key lookup

Ctrl + shift+f

Code formatting. If the code is partially selected, only the selected code is formatted

Ctrl + Shift + O

Quickly import the path to a class

Ctrl + Shift + X

Capitalize selected characters

Ctrl + Shift + Y

Convert selected characters to lowercase

Ctrl + Shift +/

Comment code block

Ctrl + Shift + \

Uncomment code block

Ctrl + Shift + M

Importing unreferenced packages

Ctrl + Shift + D

Display variable values in debug mode

Ctrl + Shift + T

Find a class in a project

Ctrl + Alt + Down

Copy the row of the cursor to its next line

Double-click the opening parenthesis (parentheses, brackets, curly braces)

All content in parentheses will be selected

Program Debugging methods

Readers in the process of program development will continue to appreciate the importance of program debugging. To verify the health of the Java unit, it used to output state information using the SYSTEM.OUT.PRINTLN () method at the beginning and end of a method invocation, and judged the program execution state based on that information, but this method is more primitive, And it often leads to confusing program code (the system is all exported.) Out.println () method).

This section provides a brief introduction to the use of the Java debugger built into eclipse, which allows you to set breakpoints on a program, implement a program stepping, and view debugging operations such as the values of variables and expressions during debugging. This avoids writing a large number of System.out.println () methods in the program to output debugging information.

The Java debugger that uses eclipse needs to set a program breakpoint, and then use single-step debugging to execute each line of program code separately. The sample code is as follows:

publicclassmytest {       publicstaticvoid main (string[] args) {              System.out.println ("Output 1 lines");              System.out.println ("Output 2 lines");              System.out.println ("Output 3 lines");}       }

1. Set breakpoints

Setting breakpoints is an essential tool in program debugging, where 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, and choose the Toggle Breakpoint command from the shortcut menu that pops up to add and remove breakpoints. To the "System. out. println ("Output 1 lines"); " Add the breakpoint as an example, as shown in 3.1.

Figure 3.1 Adding a breakpoint to the Java editor

2. Running Java programs in debug mode

To debug the MyTest program in Eclipse, you can right-click in an empty space at the Mytest.java file in Eclipse and select "Debug as" → "1 Java Application" command from the popup shortcut menu. The debugger suspends the current thread at the breakpoint, and the program pauses, as shown in 3.2.

Figure 3.2 Program execution to a breakpoint after pausing

3. 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. "Debug" View 3.3 is shown.

Figure 3.3 "Debug" view

(1) Single Step Skip

Clicking a button in the Debug View's toolbar or pressing the F6 key will perform a single-step bypass operation, running a separate line of program code, but not inside the calling method, then jumping to the next executable point and suspending the thread.

(2) Stepping into a single step

Clicking a button or pressing the F5 key in the Debug View toolbar will jump into the internal stepping program of the calling method or object and suspend the thread.

This digest from tomorrow's Science and Technology published "Java Project Development Practice", reproduced please indicate the source!!!

Introduction to Eclipse development tools

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.