Compiler




A Compiler is a program that takes as input your computer program's source code (what you write in some higher level language like Java, C++, Cobol, Fortran, Objective C, C#, etc.) and translates it into either machine code or something closer to what the CPU (central processing unit) can process. A Java compiler translates your Java classes into what is known as byte code. Java Byte code is really close to machine code, but requires an interpreter at runtime to break it down into the actual machine code that the cpu understands. The Java interpreter (or run time system) is called the JVM (Java Virtual Machine). The JVM also has other tasks that it performs (besides just translating our byte code to machine code). It also handles passing events to our appropriate methods, handling garbage collection, etc.


Source Code           The Java
(Java Program)        Compiler
                      creates
Sample.java     --->  Sample.class (contains the byte code)