Eclipse is a powerful Java integrated development tool. It can greatly improve the efficiency of our development. You can automatically compile and check for errors. In the company, Eclipse is used for development.
Download, install, uninstall of Eclipse
Download http://www.eclipse.org
Installation (can be used only after decompression)
Uninstall (only need to delete the folder to do so)
In the installation directory of the development software, try not to have spaces and use of the Chinese eclipse
Steps to use:
1. Open, select Workspace, workspace refers to the location of the future Java source files to be written. Such as:
If selected, indicates that the default workspace for Eclipse is used for the current workspace, and when you start eclipse later, you are not prompted to select a workspace.
2. Right-click on the left margin or select the File menu bar, select New--> to create the Java project name, and tap finish. Such as
3. Expand the project, select the source package src, right-click on the project's SRC directory to create the class, specify the class name Hello, create the main method and write the source code System.out.println ("HelloWorld");
4. Compiling and executing
Compile: Auto compile, automatically compile class file when Java code is saved
Perform:
- Mode 1: Click the green with Triangle Run button in the menu toolbar
- Mode 2: Click Run in the menu bar, click the running shortcut key is CTRL+F11
- Mode 3: Select the Java file you want to run, or in a blank area of your code, right-click Run as--running Java program
Simple configuration for Eclipse space
Compile and run environment of the program
- Compilation environment: Window--Preferences–java-compiler
- Operating environment: Window--preferences–java-installed JREs
How to display line numbers and hidden line numbers
Display: In the left blank area of the code area, right--show line Numbers
Hide: Do the above actions again
How to change font size and color
Modify Java code font size and color, Window--Preferences--general--appearance--Colors and Fonts--Java--Java editor Text font is selected, click Edit, and make changes.
Modify other font size and color,? Window--Preferences--general--appearance--Colors and Fonts--Bacic--click Edit when Text Font is selected and make changes.
Show the window is messed up, restore the default display mode,? Window–perspective--Reset prespective
Remove default Comments
Window--Preferences--Java--code Style--code Templates--Comments–methods, click Edit, delete the comment section (not recommended)
Window--Preferences--Java--code Style--code Templates--code--Method body, click Edit to delete the comment section
Switch workspaces
File–switch workspace– to specify a working space –ok
Shortcut keys
Content Secondary Key alt+/
Auto-Completion Main method main then alt+/
Auto-Completion Output statement SYSO then alt+/
Formatting ctrl+shift+f
Code area right--Source–format
Automatic Guide pack: Ctrl+shift+o
If the current class exists in more than one package, use Ctrl+shift+o to select a package to import.
Comments
Single-line Comment
- Add Comment: First select the content you want to comment on, then ctrl+/
- Uncomment: First select the content you want to uncomment, and then ctrl+/
Multi-line comments
- Add Comment: First select the content you want to comment on, then ctrl+shift+/
- Uncomment: First select the content you want to uncomment, and then ctrl+shift+\
Breakpoint Debugging
Breakpoint: is a marker
How to set breakpoints: a blank position to the left of the code area double-click
Where to add: to see which statement the execution result is in front of the statement plus
How to run a breakpoint program
- Code area right--Debug as--Java application
- Display a page that prompts you to go to the debug page? Do you remember the current operation? Yes (yes) Yes (tick check box)
Pop-up Breakpoint page
Point where
Click Step Over in the toolbar (to perform the next line), and the shortcut key F6 see the execution of each step of the procedure
See where
Look at the code area: procedure for taking care of a program
Look at the Debug area: Steps to take care of the program
Look at the varable area: Create, copy, destroy, watch variables
How to eliminate breakpoints
Put a breakpoint in the way you do it again
Switch to debug view, select Breakpoints--Remove all breakpoints is the 2 x icon
Deletion of items
Delete in Project area: Right-click on the specified item in the left-packageexplorer area, tap Delete to delete
Delete on hard disk: In the left Packageexplorer area, right-click on the specified item, tap Delete Delete, and select the following to delete on the hard disk (delete project contents on disk)
Import of projects
1. Right-click on the Packageexplorer area on the left and select Import
2. Choose General--Existing Projects to Workspace
3. After selecting, click Next
4. In a new window, click Browse to find the item you want to import (note that you can find the name of the item), select the item you want to import, click the Copy check box, and click Finish.
Caveats: Items with the same name already exist in eclipse cannot be imported again
Eclipse App Ctrl+t: View the inheritance tree for the selected class
For example, in the following code, selecting the teacher class name and then pressing CTRL+T will show the inheritance relationship of the teacher class
abstract class employee{ public abstract void work ();} // Lecturer class extends Employee { publicvoid work () { System.out.println ("explaining Java "); }}
View the source code for the selected class
CTRL + Slide the mouse to click on the class name, or select the class name, press F3 to see the source code of the selected class.
View the source code for the selected method
CTRL + Swipe the mouse to click the method name, or select the method name, press F3 to see the source code for the selected method.
The JRE System Library in Eclipse is the default eclipse-dependent class library in the JRE. In this location, you can find the usual string class, the random class, the math class, and so on.
Document comments Export Help document
When used with eclipse, you can work with document annotations to export a description document of the class for others to read and learn about.
Use a document comment to annotate a class or method with a simple annotation of the basic information. such as @author author, @version code version, @param method parameters, @return method return value, and so on.
PackageCn.itcast;/*** My Tool class *@authorLi *@versionVersion 1.0*/ Public classTool {/*** Returns the summation of two integers and *@paramNUM1 First Number *@paramnum2 Second Number *@returnreturns the cumulative and*/ Public Static intGetsum (intNUM1,intnum2) { returnNUM1 +num2; }}
Use Eclipse to export Javadoc documents, as follows:
Project jar package Import and export
A jar package is a compressed file that can contain many. class files. We can add a jar package to the project's dependencies so that the project can use all the classes under that jar, or you can package all the classes in the project into the specified jar package for use by other projects.
Export JAR Package: That is, all the classes in the project are packaged into the specified jar package, as follows:
Import jar Package: The specified jar package is added to the project and is provided for use by the project.
The process of importing a jar package is to add the jar package to the project's. classpath file so that the project can be identified by using all of the. class file classes in the jar package. Here are the steps to join:
- 1: Create Lib folder under Project root folder for same management of all jar files
- 2: Copy the jar file into the Lib folder
- 3: Right click on the jar file, click on Build Path, select Add to build path, and look at the. classpath file under the project root folder to find the newly added Jar package path is configured in the file. Description You can use all the classes in the jar package.
Attention:
- After the jar package is added, the add to Build path must be used to
- After the jar package is added, the classes that are added must also be guided, and if the class is joined with the same package name as the existing class package name, it is considered to be under the same package. (not common)
Java Basic Learning Note 11 Eclipse development tools