11-01 detailed tutorial of java development tool eclipse from download, installation to actual use
Introduction to eclipse and MyEclipse
Eclipse is an extensible open source ide. Started in April 1999, it was established by the IDE product development team of OTI and IBM.
In November 2001, IBM donated $40 million worth of source code to form the eclipse alliance, which is responsible for the follow-up development of this tool. Initially, it was mainly used for Java language development. Eclipse can support different computer language development by installing different plug-ins.
Eclipse: it can be used for free. In the early days, it was written by Java developers in Java language. The quick help brought by the tool fully conforms to the habits of Java programmers. Installation is free. Because it is written in Java language, it needs to provide JDK and JRE with strong expansibility. The functions that the tool itself does not have can be added through standard interface extension
MyEclipse: MyEclipse is a functional plug-in added to eclipse. At present, MyEclipse has charged fees. MyEclipse mainly provides developers with a powerful system architecture platform in the Java Web. The early MyEclipse installation needs to be based on the eclipse installation directory, and the full version will be released gradually later. After installation, it will bring eclipse, JDK and various plug-ins
Eclipse Download
Download http://eclipse.org/
Eclipse installation
Unzip the green version and use the (eclipse) installation version. Double click and run it all the way to next (JDK)
Since eclipse needs to be based on the Java environment, the runtime needs to confirm whether Java is available on the computer after installation_ Configure the home and path environment variables
Decompression path problem: it's best to be the same as that during JDK installation, without spaces or other special symbols. The software related to development should be installed in the same directory.
Eclipse directory structure:
Tips:
How to view the version of eclipse. There is one in the eclipse installation directory Eclipse product file, open it with notepad and see version = XXX to know the version
If there is a problem, delete eclipse Reboot after INI file
How to write a HelloWorld case the basic use of eclipse
1. Choose a workspace. A workspace is actually the directory where the source code we write is located
2. The code takes the project as the basic unit to create the project
3. Create package
4. Create classes and write code
5. Compilation, automatic compilation, help you do it at the moment of saving
6. Several ways of operation
Click the green triangle button behind the bug
Click run under the Run menu. You can also use the shortcut Ctrl + F11
Sinicization of eclipse and syntax checking tips
1. Sinicization
Use dropins to install the plug-in from eclipse 3 5, there is an additional dropins directory under the installation directory. Just unzip the plug-in and put it in this directory. Similarly, it is very convenient to uninstall plug-ins in this way. It is recommended that you can use both Chinese and English versions at the same time, so that you can learn English
2. Syntax check
Red - must be changed, yellow - is just a hint
Windows and views composed of eclipse
Each basic window of the window is called the window packageexplorer. It displays the project structure, packages, classes, and resources. The outline displays the structure of the class, which is convenient for finding, identifying, and modifying the results of the console program. Problems are displayed in this window. All syntax and error locations are displayed. Hierarchy displays the Java inheritance hierarchy. After selecting the class, press F4
A view is a combination of some windows. Example Java view debug view
Basic configuration of workspace in eclipse
A: Window -- preferences -- Java compilation environment: the compiler selects the highest version by default. Running environment: installed jres will find the JDK you installed by default. It is recommended to configure Java environment variables. Problem: low compile, high run. sure. High compile, low run. may not. It is recommended that the compiled and running versions be consistent.
B: 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 delete only the comment part, and do not delete the part that is not the comment part.
C: Display and hide of line numbers: right click Show line numbers in the leftmost blank area of the code area. Hide: do the above action again. D: Font size and color a: font size and color of 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 e: what if the form is messed up? Window -- reset perspective F: the console cannot be found. What should I do? Window--Show View—Console
The content auxiliary keys Alt + / are used to prompt. Main + Alt + /, South + Alt + /, and other prompts are given
Common shortcut key formatting Ctrl + Shift + F import package Ctrl + Shift + O comment line Ctrl + /; Multiple lines Ctrl + Shift + /, multiple lines cancel Ctrl + Shift + \ move the selected code up and down Alt + up / down arrow to view the source code selected class name (F3 or Ctrl + mouse click)
How to improve development efficiency a: automatically generate construction methods a: right click nonparametric construction methods in the code area -- source -- generate constructors from superclass B: right click parametric construction methods in the code area -- source -- generate constructors using fields-- Finish B: automatically generate getxxx() / setxxx() methods. Right click -- source -- generate getters and setters in the code area Corresponding shortcut key operations are provided. Alt + Shift + s press the underlined letter. C: How to inherit abstract classes and implement interfaces. D: Override means that the method overrides the parent class. If the method declaration does not match the parent class, an error will be reported.
Jar package
What is jar? Jar is a compressed package of multiple class files. What's the use of jar? Type the jar package with something written by others and select the project -- right click -- export -- Java -- jar -- specify a path and name yourself -- finish use the jar package to copy it to the project path and add it to the build path.
(1) find the jar package. (2) copy the jar package and paste it under the project path to be used. (3) add jar to the build path. classpath。 Select the jar package, right-click build path -- add to build path (4) and use it as normal.
Eclipse help documentation
Write the source program (design interface, abstract class, concrete class case), add document comments for the source program, and select the project -- right click -- export -- Java -- Javadoc -- finish
Delete item and import item delete item selected item - right click - delete delete delete from item area delete from hard disk
Import project right click in the project area, find import, find general, expand, find existing projects into workspace, click next, and then select the project you want to import. Note: the project name is selected here
Several common problems in eclipse
1. How to view the path where the project is located -- right click -- properties -- resource -- Location
2. Problems to pay attention to when importing a project: projects with the same name cannot appear in the project area (new or imported). Folders created at will cannot be imported as projects. 3. When modifying a project, do not modify the project name at will. If you really want to modify it, do not forget the configuration file In project, change this to your changed name
Precautions for receiving project files a: set up a special folder for receiving projects and do not place it at will. B: when the same item is received again, first go to the storage directory, delete the original item, then store it again, and finally refresh the item.
The advanced debugging function of code in Eclipse: the debugger views the program execution process. How to view the program execution process? To see the program process, you must set breakpoints. What is a breakpoint: it's a marker, where to start. How to set breakpoints: where you want to see the program, you can double-click on the left of the valid program. Where to set breakpoints: where not. At present: we add it to the first valid statement of each method. How to run the program after setting the breakpoint: right click -- debug as -- Java application to see where: debug: where the breakpoint test is, remember F6, or click. See the execution process of one line at a time. Variables: view program variable changes fordemo: viewed source file console: console
How to go to breakpoints: A: double click again. B: find the debug view, variables interface, find breakpoints, click, then see all breakpoints, and finally click the double fork.