->
I wanted the latest version of Sun’s JRE installed on my system, and to have it set up as the default Java Runtime Environment whenever I ran a Java executable, or Jar file. It’s actually a pretty easy process, so this is a relatively short tutorial, but I’ll cover both the 32 bit and 64 bit installations, since aside from differences in file names, the set up is identical.
Installing JRE
First, decide on which architecture will be installed, and download the relevant file from the main Java website. At the time of writing, 1.6.0 u7 can be downloaded from the following: 32 bit, and 64 bit. I wanted to install the x64 version, and so downloaded jre-6u7-linux-x64.bin to my Desktop. I also wanted to install it in its own directory in /opt, and so created a directory for it to sit in:
cd /opt
sudo mkdir java
I was also experimenting with the 32 and 64 bit versions, so made two extra directories within java:
cd java
sudo mkdir 32 64
I then copied the relevant file(s) to the respective directories, and made them executable:
32 bit:
sudo cp ~/Desktop/jre-6u7-linux-i586.bin /opt/java/32
sudo chmod 755 /opt/java/32/jre-6u7-linux-i586.bin
64 bit:
sudo cp ~/Desktop/jre-6u7-linux-x64.bin /opt/java/64
sido chmod 755 /opt/java/64/jre-6u7-linux-x64.bin
The final part of the installation simply involves executing the binary file:
32 bit:
cd /opt/java/32
sudo ./jre-6u7-linux-i586.bin
64 bit:
cd /opt/java/64
sudo ./jre-6u7-linux-x64.bin
Regardless of architecture, this should create a sub directory called jre1.6.0_07.
Setting JRE 1.6.0 u7 as Default
The process simply involves telling the system that there is an alternative Java binary available, and to use this binary to execute an “java” commands:
32 bit:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.6.0_07/bin/java" 1
sudo update-alternatives --set java /opt/java/32/jre1.6.0_07/bin/java
64 bit:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_07/bin/java" 1
sudo update-alternatives --set java /opt/java/64/jre1.6.0_07/bin/java
Follwing the second command, there should be output to the terminal something along the lines of:
Using '/opt/java/32/jre1.6.0_07/bin/java' to provide 'java'.
or,
Using '/opt/java/64/jre1.6.0_07/bin/java' to provide 'java'.
depending on the architecture installed. That’s it. Now every time “java” is run, either explicitly from the Terminal, or via a Java executable (such as the Eclipse IDE), Ubuntu will use the newly installed /opt/java/64/jre1.6.0_07/bin/java binary as opposed to the binary installed by default. Simple, eh?

(3 votes, average: 4.67 out of 5) 
Twitter
Facebook










Recent Comments