I am currently playing a lot with hudson at work, and after relative success (more posts about it coming soon) I thought I shall set it up for my virtual environments as well to push more of my projects on CI as well. However my hudson install failed for a very bizarre reason. The default jre version that was installed didn’t work very well with the winstone servlet engine that comes with it. I installed the java6 version jre as well which didn’t make any difference. Then I realised that you would manually need to tell the system which jre to use as well. As this might info might be useful for anyone else, I am documenting it here.
You can get the list of all the JRE’s installed on your instance with the following command:
rp@devbox:~$ update-java-alternatives -l java-6-sun 63 /usr/lib/jvm/java-6-sun java-gcj 1042 /usr/lib/jvm/java-gcj
To set the default jre to java-6-sun, run the this:
rp@devbox:~$ sudo update-java-alternatives -s java-6-sun No alternatives for firefox-3.0-javaplugin.so. Using '/usr/lib/jvm/java-6-sun/bin/appletviewer' to provide 'appletviewer'. Using '/usr/lib/jvm/java-6-sun/bin/apt' to provide 'apt'. Using '/usr/lib/jvm/java-6-sun/bin/extcheck' to provide 'extcheck'. Using '/usr/lib/jvm/java-6-sun/bin/HtmlConverter' to provide 'HtmlConverter'. Using '/usr/lib/jvm/java-6-sun/bin/idlj' to provide 'idlj'. .... ..
It does a whole lot of other things as well and that’s pretty much it.
I realised for my other java based apps as well, I had to update the /etc/jvm file to update the search order. This is what my file looks like, its a good idea to move your preferred jre to the top of the list.
# This file defines the default system JVM search order. Each # JVM should list their JAVA_HOME compatible directory in this file. # The default system JVM is the first one available from top to # bottom. /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-gcj /usr/lib/jvm/ia32-java-1.5.0-sun /usr/lib/jvm/java-1.5.0-sun /usr
