January 08, 2010

What is the difference between a Java compiler and a Java interpreter?

Typically, when used in that generic manner, the term Java compiler refers to a program which translates Java language source code into the Java Virtual Machine (JVM) bytecodes. The term Java interpreter refers to a program which implements the JVM specification and actually executes the bytecodes (and thereby running your program).
A Java compiler compiles source files (.java) to bytecode files (.class). Sun gives developers a free java compiler which is invoked with the 'javac' command.
A java interpreter is usually referred to as the Java Virtual Machine (or JVM). It reads and executes the bytecodes in the .class files (or in some collection of class files, like a .zip or .jar file). Sun also supplies a free version of the JVM which is invoked with the 'java' command.
Where is gets confusing is when people talk about a Just-In-Time compiler (or JIT compiler). This is actually part of a JVM. Its purpose is to take the generic (i.e. cross-platform) bytecodes and compile them into more machine-specific instructions (allowing the program to run significantly faster). Evenn though it is referred to as a JIT 'compiler', it is part of the Virtual Machine.

No comments:

Post a Comment

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts