Apr 7, 2012

Java Compiler

Your Java source code can be compiled using javac, the Java compiler. It compiles source code into bytecode for the interpreter to execute. Compiled Java code is automatically given the extension .class by the compiler.

One important change that the Java team made from C was in compiling. C is a compiled language. It outputs binary machine code, which can be run only on the machine for which it is compiled. Compiled C code executes quickly, but it is architecture-dependent. As stated before, one of the important features of Java is that it is architecture-neutral. Java accomplishes architecture independence by splitting the compiling function across two tools: the Java compiler and the Java interpreter. The Java compiler outputs bytecode, similar to machine code but written for the Java virtual machine, which doesn't exist. The interpreter verifies this bytecode, converts it into machine code of the hardware platform it is installed on, and executes it. Source code must only be written for one machine: the virtual machine. The interpreter takes care of the rest. Therefore, the Java language is both compiled and interpreted.


Post a Comment