Eclipse installation
First enter the official website of eclipsehttp://eclipse.org/ (org means non-profit organization), enter the following page
Click Download to jump
Because my computer is a 64-bit operating system, click to download and jump
Click to start downloading. After the download is complete, you will get the eclipse-inst-win64.exe file. If you don’t want to go to the official website to download it, Ah Q has prepared the installation software for you at the end of the article, and you can download it directly. Double click to install
Choose the second option for development,
Select the installation path and click the install button
Select the path of the workspace (that is, the location where the code is saved), and click Launch to run eclipse after the selection is complete , of course you have to configure JDK before, the configuration process of jdkhttps://blog.csdn.net/Qingai521 /article/details/85986598 (note: how many bits of jdk are installed, then how many bits of eclipse are used), the running results are as shown below< br>
So far, the download and installation of Eclipse has been completed.
Use of Eclipse
Eclipse is an extensible open source IDE (IDE means development tool). Double-click to open (reopen Eclipse after closing), select the workspace (the place where our code is saved), and create a new Demo project:
Select next to continue,
Right click on src to create package,
Custom package name, separated by ".",
Create class
When creating a new one, we can choose the permission public and the class that needs to be inherited, you can Select the interface to be implemented, you can choose whether there is a main method in this class,
Then write "hello world" code and run
Note:
Before building a class, you must create a package, and then build the class in the package
Only one public class is allowed in a java file (It is recommended to write only one class in a java file in the future)
One package cannot have two or more same Class of name
When creating a class, do not give the class a name Named with the name of the class provided by the JDK
In the process of writing in the class, if there is a red wave line, indicating that there is a compilation error and needs to be corrected, and the yellow wavy line indicates that you may have some minor problems, ignore it, and the compilation will not report an error!
Eclipse windows and views
Each basic form is called a window, and the view is formed by the combination of certain windows Made
PackageExplorer Display project structure, packages, classes, and resources
Outline Display the structure of the class, easy to find and identify, Modify
Console program running results are displayed in this window
span>Hierarchy displays the Java inheritance hierarchy, select the class and F4
Java view
Debug view
Eclipse's automatic basic settings span>
1) Environment configuration for program compilation and operation (general Do not change)
window -- Preferences -- Java
Compilation environment: Compiler The highest version is selected by default.
Running environment: Installed JREs will find the JDK you installed by default. It is recommended to configure Java environment variables.
Question: span>
Low compile, high run. Can.
High compile, low run. Can't.
Suggestion, compile and run the same version.
2) How to remove the default comment? window -- Preferences -- Java -- Code Style - - Code Templates Select the content you don't want, and edit it through Edit on the right.
Note: Please only delete the comment part, do not delete the part that is not the comment part.
3) color and font font size and color
a: Font size and color of the Java code area: window -- Preferences -- General -- Appearance -- Colors And Fonts --Java modification -- Java Edit Text Font
b: Console window -- Preferences -- General -- Appearance -- Colors And Fonts -- Debug -- Console font
c: other files window -- Preferences -- General -- Appearance -- Colors And Fonts -- Basic -- Text Font
4) show line numbers display and hide line numbers
Display: In the leftmost blank area of the code area, right click -- Show Line Numbers That's it. Hide: Do the above action again.
5) reset perspective The form is messed up, what should I do? window -- Reset Perspective
6) Cancel the suspension prompt window -- Preferences -- Java -- Editor -- Hovers. Uncheck Combined Hover on the right. The floating box of this code will not appear automatically. If you want to see the prompt, hover the cursor over the code and press F2.
Shortcut keys for Eclipse
ctrl + n New
ctrl + shift + f format
ctrl + shift + o import package
ctrl + / Single line comment Press it again to uncomment a single line
ctrl + shift + / Multi-line comments
ctrl + shift + Cancel Multi-line comments
ctrl + shift + t Find class
F3 or hold down ctrl and click the left mouse button View Source
ctrl + o View class structure
ctrl + 1 View tips information
ctrl + d Delete a line
alt + shift + m Extract method
alt + shift + r Rename
ctrl + alt + ↑ or ↓ Copy a row
Eclipse automatic Generate code
< /span>Right-click source and there are options to automatically generate construction methods and set get methods < /span>
or
alt + shift + s and then + c to generate an empty parameter structure
alt + shift + s and then + o Generate parameters according to local fields (member variables) Construction
alt + shift + s + r to generate get and set methods
Eclipse export jar package h5>
jar is a compressed format (similar to zip and rar formats), and jar package is a compressed package of multiple class files. Usually the B project cannot use the classes in the A project, you can export the A project into a jar package, and then import the jar package into the B project, so that the B project can use the classes in the A project.
Export jar package: select the item--right click--Export-- Java--Jar--Specify a path and a name yourself--Finish
How to import jar package: copy the jar package to the project path- -Right click--Build Path--Add to Build Path
Eclipse project deletion and import
Right click to delete (select the item and right click to select delete)
If you do not check Delete project contents on disk, only delete in eclipse
If you check Delete project contents on disk delete all in eclipse and hard disk (and do not go to the recycle bin)
Right click import (right click in the project area to find import)
1) Select Existing project into workspace in General
2) If there is a project with the same name in eclipse and cannot be imported, you can modify the project with the same name name, the shortcut key for renaming is to select the item -- alt + shift + r
3) When importing, it is recommended to check copy project to workspace, which is beneficial to the project Backup and Security
Eclipse debug
First set a breakpoint
Where you want to see the program, you can double-click on the left of the effective program .
Where to set a breakpoint: Where will not be clicked.
Currently: we just add it to the first valid statement of each method.
Then run the program after setting the breakpoint:
Right click -- Debug as -- Java Application
Right click on debug as to enter the debug view and view the following window
Debug: How does the method enter and exit the stack and which line of code is executed?
Variables: View the changes of variable values in the method
Breakpoints: How many breakpoints are there and where are all breakpoints (Variables interface , find Breakpoints, and click, then see all breakpoints, and finally click on the double fork.) Console: Console
Expressions: View the value of an expression or statement F6 Next F5 to jump into F8 jump to the next breakpoint Terminate(red button) end debug
Okay, let’s stop here today and continue tomorrow. If you want to know more learning knowledge, please follow the WeChat public account "Ah Q Shuo" to get more learning materials! You can also leave a message in the background to express your doubts, and Ah Q will answer you in a later article. Learn a little bit every day and improve a little bit every day. Eclipse download linkhttps://pan.baidu.com/s/1Rf2jUKX1QKwQwMYGcxjFpA
Articles are uploaded by users and are for non-commercial browsing only. Posted by: Lomu, please indicate the source: https://www.daogebangong.com/en/articles/detail/Eclipse%20installation%20and%20use.html
评论列表(196条)
测试