Radu Cotescu's professional blog

g33k w17h pa45510n

Using Two JVMs in Ubuntu

Today I was faced with the challenge of using two JVMs on the same machine. And let me tell you that whenever you have to do this, things get dirty. Basically I was forced to install an additional 32-bit JVM for Rodin, the IDE we use at faculty for Event-B modelling, because the developers of the platform (which is actually a modified Eclipse) decided not to support the 64-bit architectures (LAME!).

Installing a 32-bit JVM on a machine that already has a 64-bit JVM installed will change the default JVM to be the last one installed. Since all of my Java programs and application were made for 64-bit, it was a mayhem on my machine. The solution is rather simple (but, oh, so uncomfortable). You would have to change the default JVM back to the 64-bit one and build some wrapper scripts for all the 32-bit apps to use the correct JVM for them.

Changing the defaults is done in this way:

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-sun/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/java-6-sun/bin/java

The first line will instruct your system that there’s another Java version available (the old one) while the second line will make it the default version of JVM.

For Rodin, the wrapper script is pretty trivial, since it’s nothing more than a modified Eclipse IDE:

WHERE=`dirname $0`
$WHERE/rodin -vm /usr/lib/jvm/ia32-java-6-sun/bin/java

Everything should be working okay now but don’t forget to instruct the 32-bit apps to use their dedicated JVM. Anyway, keep in mind that this is an ugly hack. If you’re a developer you should better package your apps for all the available architectures and not force your user-base to do this kind of hacks. Don’t forget though that this happens only when some system dependent libraries are used (as is the case for Rodin).

How To, Java, Linux, Ubuntu

« Ubuntu 10.10 and VirtualBox Guest Additions How to install VMware Server on 2.6.35 kernels »