This article explains the process of writing a HelloWorld program in Eclipse.
Students who have just learned Java may write Java source code in Notepad, and finish compiling and running the Java program at the command prompt. Such a method is really enough to learn the basics of Java and it is the only way to understand Java better. Now the author introduces Java's most commonly used IDE tool eclipse, using Eclipse, writing, compiling, running, etc. can be done on a platform, it can even automate the production of code, comments and have a powerful error-checking function, in short, Java people will almost use this software.
Tools/Materials
- People version of Eclipse
Method/Step
Qi Gong Eclipse.
Eclipse is a green version without the need to install, after downloading the direct decompression (if the decompression process error, you can install other decompression software to try). , double-click the Eclipse.exe folder under the decompression, the software startup will be a bit long, the first launch will pop up the selection Workspace dialog box, this is to choose the directory you want to put the code to put the box below the tick, the next boot will not pop up.
New project.
1 shows the Open New Java Project dialog box, 2, fill in the project name in the dialog box, other default, then click the Finish button to complete the new project.
Create a new class.
Before we create a new class we can actually create a new package, which I skipped. 1, in the project right-click, select the New Class menu, 2, in the dialog box to fill in the class name, note the following automatic production of the main function of the tick, the other default.
Code writing.
The third one will produce the code shown in 1, and then add your own code in the original code. The code shown in Figure 2 is:
public class HelloWorld {
/**
* @param args
*/
public static void Main (string[] args) {
TODO auto-generated Method Stub
System.out.println ("Hello world!");
}
}
Program to run.
As shown in Eclipse, compile run as soon as you click on the Run button, below is the console, type we used before the command prompt. The input and output are here. If there is a compile error message, click on the error message code, the cursor will be positioned to the corresponding error code line.
Error handling.
In the fifth step, if a compile error message appears, you can click the error message as shown in Figure 1, and the software will automatically navigate to the error line. If the edit area prompts you for an error, you can put the mouse on the error prompt as shown in Figure 2, and a list of error explanations and quick processing methods will pop up.
Learn to use Eclipse to write Java programs