16 CHAPTER 1: Introducing Java Web Development
A package groups classes together. In the Name field, you can type the name of the class, which is
HelloWorld. Select the check box that gives you a main method (public static void main (String
args[])). When you’re done, you should have a class similar to the one in Listing 1-2.
- Click “Generate comments.” This will be explained soon.
Listing 1-2. A Simple Java Application
packageapress.helloworld;
/**
- A Hello World Java application
- @author Vishal Layka
*/
public class HelloWorld {
/**
- Entry point
- @paramargs
*/
public static void main(String[] args){
System.out.println("Hello World");
}
}
You can now run the application by clicking the Run button in the toolbar or by choosing Run from
the Run menu.
Eclipse then displays a console panel under the code area that shows the output of your program. In
this case, it says “Hello World.”
Javadoc Comments
A Javadoc comment begins with the /* character sequence and ends with the / character
sequence. The compiler ignores everything between these character sequences. In Eclipse, you can
add the Javadoc comments by selecting the class or method name and pressing Alt+Shift+J. To see
all the shortcuts in Eclipse, press Ctrl+Shift+L.
To generate the Javadoc, select the project in Eclipse, select the Project menu, and click Generate
Javadoc, as shown in Figure 1-9.