Install Sun JDK 6 on Ubuntu 11.10
17/11/2011 25 Comments
Update 2011-12-20: Following up on comments on the post, I added a section on how to configure the Java Browser Plugin in manual installation
Update 2011-11-25: I added the information regarding the configuration of the JDK as in my previous post Configuring Java on Kubuntu 10.10
Since Ubuntu 11.10, there is no longer an official package for the Sun/Oracle JDK. The package sun-java6-jdk is no longer officially available.
Method 1: Install a package provided by a PPA
There is a PPA (Personal Package Archives) made available by Roberto Ferramosca. To add this PPA, run the following command from the command line:
$ sudo add-apt-repository ppa:ferramroberto/java $ sudo apt-get update
You can now install the JDK with the following command:
$ sudo apt-get install sun-java6-jdk
I you’d like to install the JRE or the Java Plugin along with the JDK, use the following:
sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts
You must now set the Sun JDK as the default. You can see how to achieve this in a previous post Configuring Java on Kubuntu 10.10.
The benefit of this method is that the JDK will be updated when a newer version of the package is made available.
Method 2: Installing the JDK manually
This method consists of downloading the adequate JDK from the Oracle Web site. The file is a bin file, e.g. jdk-6u29-linux-x64.bin
The first step is to create a temporary folder where we’ll download the file.
$ mkdir -p ~/tmp/jdk-6u29 $ cd ~/tmp/jdk-6u29
Once downloaded, make the file executable and run it.
$ chmod +x jdk-6u29-linux-x64.bin $ ./jdk-6u29-linux-x64.bin
Now copy the file to the preferred target location, e.g. ~/dev/jdk
$ mkdir -p ~/dev/jdk $ cd .. $ mv jdk-6u29 ~/dev/jdk/
Let’s now create a symbolic link so that we can easily update with newer versions in the future.
$ cd ~/dev/jdk $ ln -s jdk-6u29 jdk-6
The next step is to add to the ~/.bashrc the path to our JDK binary files.
#Use the symbolic link export JAVA_HOME="~/dev/jdk/jdk-6" export PATH=$PATH:$JAVA_HOME/bin
The benefit of this method is that one can install any version of the JDK (6 or 7). The downside is that one must manually upgrade the JDK.
Manually configuring the browser plugin
To configure the plugin, you need the JRE that comes with the JDK. If you installed the JDK in $JAVA_HOME, the JRE is located in $JAVA_HOME/jre.
Based on some documentation that I found on Oracle Web Site, the solution is simply to create symlinks to the plugin. The plugin can be found in
- $JAVA_HOME/jre/lib/amd64/libnpjp2.so for 64bit machines
- $JAVA_HOME/jre/lib/i386/libnpjp2.so for 32bit machines
You can go to http://javatester.org/version.html to check that the plugin works fine.
Configuring the plugin for Firefox
Create a symlink to the plugin
$ sudo ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so /usr/lib/firefox-addons/plugins/libnpjp2.so
This shall do the trick.
Configuring the plugin for Chromium
Create a symlink to the plugin
$ sudo ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so /usr/lib/chromium-browser/plugins/libnpjp2.so
With Chromium, it is necessary to enable plugins. You can just launch it from the command line once to enable the plugins with the following command
$ chromium-browser --enable-plugins %U
If you now naviate to chrome://plugins/, you shall see something like:
Java – Version: 184.108.40.206
The next generation Java plug-in for Mozilla browsers.