I\'ve heard that the advantage of java is that people can write code, compile it for the JVM, and run it anywhere. Each person just needs a JVM app for their platform.
The main advantage, to me, is the library portability. Libraries might have version dependencies between themselves, but, other than that, a JAR just works.
There is the so-called classloader hell, but that's not nearly as common.
In most other languages, you either have to find the correct library binary, or you have to download the sources to install it.
Besides the advantages of the JVM that will allow you to execute code independently of the CPU architecture with reasonable performance thanks to the JIT-compiler, one fundamental advantage of Java is that it's not just a programming language, but a runtime environment with a API common to all the underlying platforms on which it can run (there are some differences occasionally, but they tend to be bugs).
gcc
(GNU Cross Compiler), for example, will let you compile C code for more or less any platform. That's fine in principle for anything that's limited to using calls in stdio.h
and a few others. However, you'll run into trouble quite quickly as soon as you try to use something a bit more OS specific, which tends to appears quite quickly: GUI, some I/O, threading, processes, networking.
As soon as you get an #include <win32.h>
or similar in your C code, you'll have to rewrite parts of the code to port it to a Linux/OSX platform, some of this work may not be obvious or directly possible.
The advantage of Java isn't just its virtual-machine and ability to read and run the same bytecode on any platform, it's also the availability of a rather large library as part of the JRE (for example J2SE) and a common threading and networking model.