->
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?
| US $415.25 (30 Bids) End Date: Thursday Dec-04-2008 12:40:00 PST Bid now | Add to watch list |
| US $660.00 (38 Bids) End Date: Thursday Dec-04-2008 12:50:00 PST Bid now | Add to watch list |
| US $600.00 (29 Bids) End Date: Thursday Dec-04-2008 12:58:07 PST Bid now | Add to watch list |
| US $436.00 (29 Bids) End Date: Thursday Dec-04-2008 14:46:24 PST Bid now | Add to watch list |
| US $871.00 (32 Bids) End Date: Thursday Dec-04-2008 16:01:14 PST Bid now | Add to watch list |
| US $860.00 (40 Bids) End Date: Thursday Dec-04-2008 17:03:45 PST Bid now | Add to watch list |
| US $699.00 (1 Bid) End Date: Thursday Dec-04-2008 19:06:34 PST Bid now | Add to watch list |
| US $590.00 (20 Bids) End Date: Thursday Dec-04-2008 19:08:00 PST Bid now | Add to watch list |
Related posts:
- Eclipse PDT IDE for PHP MySQL 32 Bit install on 64 Bit Ubuntu
- 64 Bit Azureus BitTorrent Client with 64 Bit JRE
- Ubuntu 8.04 Hardy Heron Vs. Windows Vista SP1: The big showdown
- Watch Live Premiership and Champions League Matches via Sopcast, on Ubuntu Hardy/Debian 32 & 64 Bit
- Compiz and Emerald problem after Ubuntu Hardy Heron Upgrade
Related posts brought to you by Yet Another Related Posts Plugin.

(3 votes, average: 4.67 out of 5) 




















August 5th, 2008 at 8:03 pm
[...] Update Java Filed under: Linux — 0ddn1x @ 2008-08-05 20:03:18 +0000 http://www.64bitjungle.com/ubuntu/install-java-jre-160-update-x-on-hardy-as-the-default-java-runtime... [...]
August 10th, 2008 at 11:09 am
Nice, thanks! Any tips about getting the 64 bit java working with firefox?
August 10th, 2008 at 11:48 am
Hi Bakunin,
Thanks - glad it helped. Unfortunately, there isn’t a plugin as yet for 64 Bit JRE (or JDK) - hopefully, one will be available soon, since I’d like to use it too
I’ll update the tutorial as soon as one becomes available
September 14th, 2008 at 10:44 pm
i did the installation and evericing was write… no problems there, but now when i type java -version i received this mensage Command ‘java’ is available in ‘/usr/bin/java’
bash: java: command not found
i tried to test the java version on the sun site and give error no java found
what may be the problem…. i haven’t no error in the installation…
please help…
September 21st, 2008 at 10:25 am
I cannot get this update to work, period. Nothing works. I get the .bin in a folder then it won’t let me copy into the /usr/bin/jvm folder so I went to command line from the GRUB and copied it manually. Still won’t install. Won’t even recognize it as an alternative and now I can’t delete it without going back into the command line from the GRUB. For that matter, System says it cannot find the alternative no matter where I put it or how I put it there. WTF? All I get is cannot stat jre1.6.0_07 not found. It’s in there so many damn times I can’t get it out of some of the directories. Also says command not found sometimes and I’ve tried it on multiple directories where I have put jre-1.6.0_07. I’m about to scrap Ubuntu if I can’t get this loaded. I need it to access my work files.
September 21st, 2008 at 12:51 pm
ZEUS - did you get any error messages when you ran the sudo update-alternatives –install… command? It sounds like you may have run the .bin file ok, but it probably hasn’t installed correctly with update-alternatives. Try running the commands again, and if there are any error messages post them here and I’ll see if I can help further.
September 21st, 2008 at 1:03 pm
Levi - Don’t install via GRUB - very bad idea
You have to do it via the terminal once Ubuntu has booted up (Applications -> Accessories -> Terminal). It sounds like it could be permissions - are you copying the file with “sudo”? Assuming you have the 64bit version:
sudo cp jre-6u7-linux-x64.bin /usr/bin/jvm
Although I would recommend creating the folder either in /usr/java
sudo mkdir /usr/java
Or in /opt
sudo mkdir /opt/java
Then, copy the .bin file from your download directory to the new dir - again, using sudo, which gives you the correct admin permissions to copy the file:
sudo cp jre-6u7-linux-x64.bin /usr/java
Once it has copied, go to the directory and make the file executable:
cd /usr/java
sudo chmod 755 jre-6u7-linux-x64.bin
Then run the file:
sudo ./jre-6u7-linux-x64.bin
This will create a directory called “jre1.6.0_07″ so the full path to it will be:
/usr/java/jre1.6.0_07
Once you have this directory, you can run:
sudo update-alternatives –install “/usr/bin/java” “java” “/usr/java/jre1.6.0_07/bin/java” 1
(All one command!) followed by:
sudo update-alternatives –set java /usr/java/jre1.6.0_07/bin/java
Remember to use “sudo” before each command - this will give you the correct permissions to copy and run everything.
If you have any more problems please post them here, and I’ll see if I can help further.
October 4th, 2008 at 6:48 am
Please Help
sudo ./jre-6u7-linux-x64.bin
agreement…
yes
Unpacking…
Checksumming…
Extracting…
./jdk-6u7-linux-x64.bin: line 480: ./install.sfx.13618: cannot execute binary file
Failed to extract the files. Please refer to the Troubleshooting section of
the Installation Instructions on the download page for more information.
paatap@paatap-server:/usr/java/64>
October 4th, 2008 at 7:11 am
Paatap - it looks like it could be a corrupt archive. Have you tried downloading the file again? Hopefully grabbing a new copy will solve the problem
October 4th, 2008 at 7:38 am
i traied same file on fedora 8 x 64 -no problem
is this problem of suse?
October 10th, 2008 at 6:01 am
Thank you. This java update has been very annoying to update. I finally got it to work though. I appreciate the help. The open source community will destroy windows foundation as a licensed operating system. I can now do everything I need in linux from Pro audio to video editing, office programs, font creators, graphic design. This is great. I’ll be donating some money to the programmers ASAP. The open source philosophy is the only good philosophy whether you are talking about software or business transactions. Anything that promotes a win/win environment is beneficial for the whole planet. I hope this philosophy can offer politicians a real way to fix the health care systems as well as help capitalistic vampires like MBNA write a bankruptcy law that doesn’t screw over the middle class and the impoverished. One can only hope for the best and prepare for the worst. Thanks again.
November 29th, 2008 at 11:41 pm
Great article, some apps ( ie Tomcat ) seem to still need a JAVA_HOME defined. This should be ( using the paths above and the 32 bit version ) :
export JAVA_HOME=/opt/java/32/jre1.6.0_07/