3.5.2 Compiling the application

Previous Index Next 


The next step in the process is to take the HelloWorld.java file we created in section 3.5.1 and compile it. The Java compiler takes a java source file (.java) and compiles it into a Java class file (.class). The Java class file contains the byte code that is interpreted by the Java VM.

The java compiler is called javac.

Move to the same directory that you saved HelloWorld.java into and execute the following command:

javac HelloWorld.java
The Java compiler will now compile the HelloWorld.java file. If there are any errors the Java compiler will list the line number and describe the errors. If you have any errors correct them and rerun the compiler.

Once the compile is successful you will find you now have a HelloWorld.class file. This is the compiled class file generated from the HelloWorld.java file.


1