Managing Java installations

So apparently many Linux developers don’t like the license that comes with Sun’s Java/JDK implementation. As a result, Ubuntu’s default implementation is OpenJDK, an open source alternative. The more conservative Debian doesn’t ship with any JDK installed.

For the most part, the Sun JDK and OpenJDK are identical. However, one area in particular where OpenJDK support is poor is Java Web Start. I recently traced a very frustrating issue to some sort of bug in OpenJDK’s web start support, and just yesterday a colleague in my lab experienced a similar problem. I helped her install Sun’s JDK and the issue was resolved.

Since I’ve had to install Java a few times recently, I’ve been thinking about “the right way” to manage Java installations on my machine. One of my undergrad professors told me horror stories about software that required specific (older) versions of Java and the pain of managing the current version along with the older versions. I don’t know if I’ll ever have to deal with that, but I’ve come up with a strategy today that I think will work well.

Download the latest JDK from Sun’s website, open a terminal, and then change to the download directory. The following commands will then install Java on your machine. Note: slight adjustments may be necessary if you’re not using a Debian-based distribution.

sudo mkdir /usr/local/java
chmod 755 jdk-6u24-linux-x64.bin
sudo mv jdk1.6.0_24/ /usr/local/java/.
sudo ln -s /usr/local/java/jdk1.6.0_24 /usr/local/java/jdk
sudo sh -c 'echo "export PATH=/usr/local/java/jdk/bin:\$PATH" >> /etc/bash.bashrc'

Then, if you ever need to install a different version of Java, you can repeat steps 2-4 with the new version (and step 5 if you want to make the new version the system-wide default).


One comment

  1. Pingback: Setting up {OpenGrok for source code browsing « BioWize

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s