You may have noticed that I also checked off the box asking Eclipse to generate the main method for me.Click Finish, and in a couple of seconds Eclipse will generate for you the initial code for the class HelloWorld, as shown in Figure 1
 |
| Figure 1 |
The generated code is shown in Eclipse’s editor view. It starts with the package statement, and the class declaration with the method name goes next. Type in the line System.out.println(“Hello World”); under the TODO comment (comments are explained in the next section), and save the code by pressing the little diskette image on the toolbar or using the Ctrl+S key combination. As you type in the code, Eclipse displays context-sensitive help suggesting a selection of possible values, minimizing guesswork and typing errors. I made a snapshot, shown in Figure 2 right after entering System.o
 |
| Figure 2 |
By default, saving the code results in an invocation of the compiler. If you didn’t make any syntax errors, Eclipse will create HelloWorld.class in the bin directory of the Hello project. In case of compilation errors, Eclipse puts a little red round bullet in front of problematic lines. Now you can run the program by pressing the round green button on the toolbar. The output of the program will be shown in the Console view panel in the lower part of Eclipse IDE, as in Figure 3
 |
Figure 3
|
No comments:
Post a Comment