Compiling a Java Program


javac HelloWorld.java



In this phrase, we compile the HelloWorld.java source file to bytecode. Bytecode is Java's platform-independent representation of a program's instructions. The output will be placed in the HelloWorld.class file.

The javac executable is included with the Java JDK distribution. This javac program is used to compile the Java source files that you write into Java class files. A java class file is a bytecode representation of the compiled java source. For more complete information about the javac command, be sure to see the JDK documentation. There are many options you can use with javac that are not covered in this book.

For most programming projects, other than very small and simple programs, you will most likely use an IDE or a tool, such as the Ant build tool from Apache, to perform your compiling. If you are compiling anything other than a very small project with minimal source files, I highly recommend that you become familiar with Ant. If you are familiar with the Make build tool commonly used by C programmers, you will understand the importance of Ant. Ant is like a Make tool for Java. With Ant you can create a build script that will allow you to specify details of how a complex application should be built, and with a single command you can automatically build the entire application. You can get more information about Ant and download it from http://ant.apache.org.




JavaT Phrasebook. Essential Code and Commands
Java Phrasebook
ISBN: 0672329077
EAN: 2147483647
Year: 2004
Pages: 166

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net