A Java compiler is a program that takes the text file work of a developer and compiles it into a platform-independent Java file. Java compilers include the Java Programming Language Compiler (javac), the GNU Compiler for Java (GCJ), the Eclipse Compiler for Java (ECJ) and Jikes.
Programmers typically write language statements in a given programming language one line at a time using a code editor or an integrated development environment (IDE). The resulting file contains what are called the source statements. The programmer then runs a compiler for the appropriate language, specifying the name of the file that contains the source statements.
At run time, the compiler first parses (analyzes) all of the language statements syntactically and then, in one or more successive stages or "passes,” builds the output code, making sure that statements that refer to other statements are referred to correctly in the final code.
Generally, Java compilers are run and pointed to a programmer’s code in a text file to produce a class file for use by the Java virtual machine (JVM) on different platforms. Jikes, for example, is an open source compiler that works in this way.
A JIT (just in time) Java compiler comes along with the Java VM. Its use is optional, and it is run on the platform-independent code. The JIT compiler then translates the code into the machine code for different hardware so that it is optimized for different architectures. Once the code has been (re-)compiled by the JIT compiler, it will usually run more quickly than the Java code that can only be executed one instruction at a time.
Learn how to install Java and the JDK