CHAPTER 1: Introducing Java Web Development 13
Note Every Java application has only one main method.
You use the javac program in the bin directory of your JDK installation directory to compile Java
programs. Assuming you have edited the PATH environment variable on your computer, you should
be able to invoke javac from any directory. To compile the HelloWorld class in Listing 1-1, do the
following:
- Open a command prompt and change to the directory where the HelloWorld.
java file is saved. - Type the following command:
javac HelloWorld.java
If everything goes well, javac will create a file named HelloWorld.class in your working directory.
Running Your Java Application
To run your Java application, you have to use the java program that is part of the JDK with the
command java
able to invoke java from any directory. From your working directory, type the following:
java HelloWorld
Note that you do not include the .class extension when running a Java application. You will see the
following on your console:
Hello World.
Developing Java Applications with an IDE
In this book you will use the Eclipse Kepler integrated development environment (IDE). To download
it, follow these steps:
- Open http://www.eclipse.org/downloads/ in a web browser.
- Follow the instructions provided by the web site.
- Run the installer and accept any defaults.
Creating Your First Project in the IDE
After you’ve started Eclipse, you can make a new project as follows:
- From the File menu, select New, and then select Project. The New Project
window appears. - In the New Project window, double-click Java Project. The New Java Project
window appears, as illustrated in Figure 1-7.