You are here: Foswiki>Cosmo Web>ComputerLanguages>JavaVirtualMachines (revision 3)EditAttach


Java Virtual Machines (JVM) and compilers

which one to chose?

When choosing to use Java as your programming language there is always the choice of a particular implementation of Java. There are a few choices. What is nice is that they are absolutely free but does not meen they have to be open (-source). You can use them for any purpose you want - see the corresponding licences. In that sence they are free. Hovewer Java itself is a trademark of Sun Microsystems and that is Sun that is in charge when it comes to extend the language, introduce new specifications etc.

One more word about what you need to write your Java soft and what is the JVM itself. Java is different from compiled languages like C, C++ or Fortran. Those languages are compiled to the native code that can be executed directly by the computer. With Java it is different - source code is compiled to the bytecode - universal code that can be executed by the Java Virtual Machine, NOT the computer/cpu itself. So there is one more step. JVM's role is to translate the bytecode to the native code so it can be executed.

Very old JVMs where just interpreters and very very slow. Modern JVMs use diffrent technologies like HotSpot or JIT (Just In Time compiler). The bytecode is being compiled "on the fly" (JIT) to the native code and thanks to HotSpot it is also very wisely optimized (main rule is that the most commonly used code is optimized the most, depending on the usage - this is certainly big advantage over "static" optimisation of native-code compilers which does not have to be smart). In fact modern JVM performance is comparable to C/C++.

Why bytecode? The idea of Java was to compile once - run anywhere. Your compiled soft can be run on Linux, Mac, Windows... anywhere you want without any change provided there is a JVM on the computer. This is the best portability you can have.

And here is the choice:

Sun J2SE (Standard Edition is what you want. Currently ver. 1.4.2)

The reference implementation, quite nice but not the speed-deamon. Features JIT and HotSpot. If you want to start with Java - this is certainly what you need. http://java.sun.com - and many specifications/tutorials/forums etc. to downlad go to j2sdk (soft. development kit)

Blackdown Java (v. 1.4.1)

Blackdown is an organisation that is porting Sun's Java to Linux. In fact the SDK you can get from Sun's website is based on the Blackdown's version. I can not see any big reason for using this version. http://www.blackdown.org

IBM SDK (currently v. 1.4.1)

Certainly the fastest JVM you can find! And that is the one that is suitable for numerical works! Features the best JIT technology which is supreme over Sun's version. In benchmarks such as Scimark2 the mean performance is about 150%-180% (sic!) of the Sun's JVM. Some tasks go even 4 times faster! In everyday-use there is also a nice boost in speed. Highly recommended! What is really nice is that Scimark2 in Java and in C give almost the same results when using this JVM!!! http://www-106.ibm.com/developerworks/java/jdk/linux140/

BeaLogic (JRockit)

(to be written)

Kaffe (hard to determine the version. the project is lazy.)

Open-Source and 100% implementation of Java. But since Java is a trademark, it is not Java from the formal view. Does not matter. What matters is that there is a development version that is quite nice. But I do not recommend using it. It is very slow, not extremely stable. The only + is that it is 100% free and open. Scimark2 gives results 4x lower than using Sun's JVM. http://www.kaffe.org

Jikes - open-source, free - compiler only (no jvm)

(to be written)

gcj - native-code compiler. Java interface for gcc

This one is worth attention for sure! Gcj can compile both .java sourcefiles and .class bytecode to native code. So what you get is an executable. Just like C or Fortran. Quite nice performance, but still comparable to Sun's JVM. What is very attractive is that it is 100% free and GPL. Does not recognize all the Java features. Is against portability. However it compiles my numerical software wink But is not stable - compiled software sometimes throw Exceptions (in my case) which does not happen when using other JVMs. But uses much less memory that JVMs.

My (Michal Frackowiak) recommendations:

If you start with java, get Sun's version. There is no problem in switching later. Forget Kaffe, do not care about gcj. Treat it as sth interesting - you can experiment with it. Than switch to IBM's JVM as soon as possible. You can use Jikes as your compiler, but for me it is certainly not necessary. Rather than experimenting with JVMs - as me wink - start writing good software with good documentation! wink

The not-a-very-nice-thing is that open-source and community-maintained code does not compete well with solutions provided by the "bigfish". The nice thing with it is that Sun and IBM put a lot of effort to bring what is the best for Java. And results can be seen - a few years ago Java was considered a terribely slow language. Some people still believe it. There are many disadvantages of Java but certainly it is not slow! Another nice thing is that there are several great development software (also open-source and free!) - Java is the language that is being used for serious tasks, not only for "Hello World".

-- MichalFrackowiak - 13 Nov 2003
Edit | Attach | Print version | History: r6 | r4 < r3 < r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r3 - 13 Nov 2003, MichalFrackowiak
 
This site is powered by FoswikiCopyright © CC-BY-SA by the contributing authors. All material on this collaboration platform is copyrighted under CC-BY-SA by the contributing authors unless otherwise noted.
Ideas, requests, problems regarding Foswiki? Send feedback