Java performance and optimization
Why is Java so slow?
Java is an interpreted language. As as consequence, Java is never going to be as fast as compiled language like C. The bytecode generated by the compiler must be interpreted at runtime.
The performance of Java's interpreted bytecode is anyway much better that scripting languages such as Perl. Many Java interpreters now include a "Just-in-time" compiler.
What factors contribute to Java performance?
Hardware, operating system and the Java Virtual Machine contribute to Java performance. Don't forget to check the Personal Java page and the Java chips page.
is the industry-standard tool in Java performance benchmarking. It has many strengths and is the most widely accepted test available today.
Optimizing Java
There are basically two way for optimizing Java:
Just-in-time compilers
Many Java interpreters now include a "Just-in-time" compiler. After reading in the .class file for interpretation, it hands the .class file to the JIT. The JIT will take the bytecode and compile it into native code for the machine that you are running on. It can actually be faster to grab the bytecode, compile it, and run the resulting executable than it is to just interpret it.
If you call the same method more than once, you do not have to re-JIT the method and can simply re-execute the native code.
The JIT is an integral part of the Java Virtual Machine, so you never notice it's there, except your Java runs faster. Some environments allow you to choose whether or not to JIT code.
Here is a list of "Just-in-time" compilers:
Kaffe bytecode interpreter
- Symantec JIT compiler
This page was last updated 06 March 1998