Custom Search

Java Compiler - JavaC

A Java Compiler is a computer program or set of programs which translates java source code into java byte code. The most commonly used Java compiler is javac, included in JDK from Sun Microsystems.

When we write a Java program we use a text editor like Notepad to write the source code. We then use Java compiler to compile it. We therefore have to be careful that the syntax we use is correct - so that the compiler will understand it! When we are happy with our program we save it with the appendage or extension .java (we save it as a java file). The name we give it doesn't matter - but should be something which means something to you. For example, if the code drew a circle we might call it circle.java.

We then use the compiler to compile the Java file. Javac generates bytecode for the java source file and saves in a class file with a .class extension. Our file would be circle.class.  This file contains instructions that a JVM (Java Virtual Machine) can interpret; it can read a ".class" file, but not a .java file.

Once the byte code is generated it can be run on any platform using Java Interpreter (JVM). It interprets byte code (.class file) and converts into machine specific binary code. Then JVM runs the binary code on the host machine.