Java Reference
In-Depth Information
Every Java application has only one main method.
Note
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:
1.
Open a command prompt and change to the directory where the HelloWorld.
java file is saved.
2.
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 <class name> . Again, having added the PATH environment variable, you should be
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 topic you will use the Eclipse Kepler integrated development environment (IDE). To download
it, follow these steps:
1.
Open www.eclipse.org/downloads/ in a web browser.
2.
Follow the instructions provided by the web site.
3.
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:
1.
From the File menu, select New, and then select Project. The New Project
window appears.
2.
In the New Project window, double-click Java Project. The New Java Project
window appears, as illustrated in Figure 1-7 .
 
Search WWH ::




Custom Search