Install Java JRE 1.6.0 (Update x) in Linux as the Default Java Runtime, including Firefox Browser Plugin
Posted by Hodge on Aug 2, 2008 in Featured, Linux, Ubuntu • 82 comments •

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.
Changelog
Update 12/10/09: JRE 1.6.0 u16 now available!
Update 19/08/09: JRE 1.6.0 u15 now available!
Update 29/06/09: JRE 1.6.0 u14 now available!
Update 29/03/09: JRE 1.6.0 u13 now available!
Update 05/02/09: Updated for u12, which now includes the 64 bit Browser Plugin!
Installing JRE
First, decide on which architecture will be installed, and download the relevant file from the main Java website – if you’re running a 64 Bit Linux OS, download the 64 Bit JRE.
At the time of writing, 1.6.0 u16 can be downloaded from the following: 32 bit JRE, and 64 bit JRE. I wanted to install the x64 version, and so downloaded jre-6u16-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 moved the relevant file(s) to the respective directories, and made them executable:
32 bit:
sudo mv ~/Desktop/jre-6u16-linux-i586.bin /opt/java/32
sudo chmod 755 /opt/java/32/jre-6u16-linux-i586.bin
64 bit:
sudo mv ~/Desktop/jre-6u16-linux-x64.bin /opt/java/64
sudo chmod 755 /opt/java/64/jre-6u16-linux-x64.bin
The final part of the installation simply involves executing the binary file:
32 bit:
cd /opt/java/32
sudo ./jre-6u16-linux-i586.bin
64 bit:
cd /opt/java/64
sudo ./jre-6u16-linux-x64.bin
Regardless of architecture, this should create a sub directory called jre1.6.0_16.
Setting JRE 1.6.0 u16 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_16/bin/java" 1
sudo update-alternatives --set java /opt/java/32/jre1.6.0_16/bin/java
64 bit:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_16/bin/java" 1
sudo update-alternatives --set java /opt/java/64/jre1.6.0_16/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_16/bin/java' to provide 'java'.
or,
Using '/opt/java/64/jre1.6.0_16/bin/java' to provide 'java'.
depending on the architecture installed.
To double check everything is as it should be, in a Terminal run:
java -version
This should output something along the lines of:
java version "1.6.0_xx"
Java(TM) SE Runtime Environment (build 1.6.0_xx)
Java HotSpot(TM) 64-Bit Server VM (build xxxx, mixed mode)
That’s it. Now every time “java” is run, either explicitly from the Terminal, or via a Java executable (such as the Eclipse IDE), the newly installed /opt/java/64/jre1.6.0_16/bin/java binary will be used as opposed to the binary installed by default. Simple, eh?
Installing the Browser Plugin
Note: For the 64 bit plugin, it is strongly recommended that you use the version of Firefox available for installation via your distribution’s repositories.
As with most Firefox plugins, they can be installed in ~/.mozilla/plugins – if it doesn’t exist, it can be created:
mkdir ~/.mozilla/plugins
It may also be necessary to uninstall any previous Java installations, such as IcedTea etc.:
sudo apt-get remove icedtea-gcjwebplugin
Note: if you’re upgrading from a previous JRE install, remove the old plugin first:
32 Bit:
rm ~/.mozilla/plugins/libjavaplugin_oji.so
64 Bit:
rm ~/.mozilla/plugins/libnpjp2.so
The Plugin can now be installed by either copying the file:
32 Bit:
cp /opt/java/32/jre1.6.0_16/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins/
64 Bit:
cp /opt/java/64/jre1.6.0_16/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
or by creating a symbolic link to the file (this is the best option)
32 Bit:
ln -s /opt/java/32/jre1.6.0_16/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/plugins/
64 Bit:
ln -s /opt/java/64/jre1.6.0_16/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
Once installed, restart Firefox. There are two methods to see if the Plugin is installed – navigate to about:plugins
or to the Java Tester Page
That’s it. Enjoy ![]()
Something not quite right? Inaccuracies or invalid code? Didn’t work for you? Don’t like me using Ss instead of Zs? Add a comment below! All comments are welcome. Except spam, because spam is a bit crap.
|
|
… |
|
|
… |
|
|
… |
|
|
Goldengulf 9 inch dual camera Latest MID Google Android 4.0 Tablet PC Capacitive Allwinner A13 8GB Flash 11.1 $92.50 Features: Capacitive MultiTouch screen |
|
|
7” A13 Google Android 4.0 AllWinner Tablet Boxchip Cortex A8 1.2Ghz MID Capacitive Touch Screen G-sensor WIFI, Camera, Skype Video Calling, Netflix, Flash Supported Dragon Touch(TM) MID7134B [By TabletExpress] (4GB Black) $60.00 TabletExpress is ONLY one authorized distributor by Dragon Touch(TM) in North America.Buy genius Dragon Touch (TM) tablet from TabletExpress only. Specification: Operation system: Android 4.0 Support HD Flash 11 Main IC: Allwinner A13 (CPU+ GPU+ VPU) Cortex A9 1.2G Screen: 7 inches 5 Points Capacitive Touch 16:9 .800 * 480 Storage: 4GB Memory: DDR3 512MB Storage Extend: 128MB-32GB SD/TF Sup… |







This was a great tutorial. Simple, straight-forward, and complete. It worked perfectly. Now, if only there was a way to get my system to recognize the latest JDK…
Finally!!! I’ve been all over the net, or so it seems, trying to find out how to get this to work. I’m using Ubuntu 8.10 Intrepid AMD64. I installed a download manager, FreeRapidDownload a few days ago, but when I tried to run it, it came back and told me to forget about it because it wasn’t going to run with the buggy Java 1.6.0_0 on my system!
Last night I went to Sun and downloaded the 64 bit version and installed it, but of course without instructions, this didn’t get me anywhere. Earlier, I had removed the two Java packages I found in Synaptic, but apparently that wasn’t enough because the old version was still working on my system.
These were the commands (my versions) that should have been at all the sites I visited!!
sudo update-alternatives –install “/usr/bin/java” “java” “/usr/java/jre1.6.0_14/bin/java” 1
sudo update-alternatives –set java /usr/java/jre1.6.0_14/bin/java
Your other commands for the sym links and for what and how to remove IceTea also were key to success. I’ll remind others that you must shut down and restart the browser, FF, to see if IcedTea is gone from About:Plugins. I had to do it a couple of times.
This is more important to me than just enabling me to check out a new download manager. I’m currently looking into setting up a backup system, and I just found a promising program to use, Areca, but it’s Java based. I didn’t feel safe using it with the “buggy” version of Java I had, but now I have no excuse not to forge ahead and begin playing it safe with a proper backup program.
THANK YOU!!!! What a find!!
Could add the plugin to update-alternatives using –slave so when you do
sudo update-alternatives –config java
the plugin will be updated as well.
I have this cuestion. Im trying to update the virtual machine in my ubuntu computer, so i did, i download the 1.6.0_145 version but i dont know how to firefox 3.0.11 get the same update. When i enter to this site http://www.javatester.org/version.html, results that the version i have is 1.0.6_0 … how can i update firefox too?
when i enter in my terminal in ubuntu:
$ java -version
this is the output:
java version “1.6.0_14″
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
can someone help me please??
thanks
a 5 is extra in the version i try to write sorry…
1.6.0_14 this is the latest one i think
Hi Emesto,
You’ll need to first delete the old plugin from your Firefox plugins directory:
For 32 Bit:
rm ~/.mozilla/plugins/libjavaplugin_oji.soFor 64 Bit:
rm ~/.mozilla/plugins/libnpjp2.soThen copy the new plugin file:
for 32 bit (Check where you have installed it for the directory path)
cp /opt/java/32/jre1.6.0_14/plugin/i386/ns7/libjavaplugin_oji.so ~/.mozilla/pluginsFor 64 Bit:
cp /opt/java/64/jre1.6.0_14/lib/amd64/libnpjp2.so ~/.mozilla/pluginsRemember to restard Firefox too. I hope that helps
jre for 32 bit and 64 bit system
Better!
sudo ln -s /opt/java/64/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/
It worked fine till i execute thwese two commands,
sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/64/jre1.6.0_13/bin/java” 1
sudo update-alternatives –set java /opt/java/64/jre1.6.0_13/bin/java
No errors and i didn’t see any output on the screen either. Java -version gimme the same old java 1.5
what went wrong any guess??
Regards,
Anandh
I tried this on Ubuntu 9.04 and JDK 1.6 update 14
It worked without any issues and my 64 bit JRE is up and running along with firefox plugin and Eclipse IDE.
Thanks a ton for posting these steps. One of the best I have seen
I seem to have the same problem as Anandh (July 16). Running:
sudo update-alternatives –install “/usr/bin/java” “java” “/opt/java/64/jre1.6.0_13/bin/java” 1
seems to go OK and returns to the prompt.
Then, when I run
sudo update-alternatives –set java /opt/java/64/jre1.6.0_13/bin/java
I get an error message “update-alternatives: Vaihtoehtoa “/opt/java/64/jrel.6.0_14/bin/java” ei löydy.” meaning that the option “/opt/java/…” is not found.
Commanding sudo update-alternatives –config java gives me:
There are 4 alternatives which provide `java’.
Selection Alternative
———————————————–
*+ 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java
2 /usr/lib/jvm/java-gcj/jre/bin/java
3 /usr/bin/gij-4.2
4 /usr/lib/jvm/java-6-sun/jre/bin/java
When I look in the directory /opt/java/64/jre1.6.0_13/bin/ I can see the green java file, there. (Sorry that I call it ‘green’. I don’t really know what it stands for and if its right or not).
Any ideas, anyone, please?
just a tip for firefox 3.5 users :
i followed the instructions verbatim and everything worked up until the browser plugin check….
i had my version of ff 3.5 installed in /home/me/firefox which is where i had to install it so ubuntu didnt default back to 3.0.xx. for some reason, even though i had the jre1.6.0_15 file linked to my /home/me/firefox/plugins, it was not recognizing it. i had to link that file to /usr/lib/firefox/plugins and it picked it up. otherwise everything went great. kudos to Hodge for such a detailed guide. i finally got java 1.6.0_15 working with ff 3.5!
P.S. i forgot to add that you must “sudo su” and “rm /usr/lib/firefox/plugins/flashplugin-alternative.so” before starting
in order to remove the plugin it is using (this was my case at least) hope this helps.
Thanks! It worked beautifully! How come this specific info is NOT under the installation instructions on Sun’s site?
Thanks, I’ve done all these, it seemed to went fine, but Firefox 3.5 doesn’t get it. Jason wrote something like this in one of the comments:
“i had my version of ff 3.5 installed in /home/me/firefox which is where i had to install it so ubuntu didnt default back to 3.0.xx. for some reason, even though i had the jre1.6.0_15 file linked to my /home/me/firefox/plugins, it was not recognizing it. i had to link that file to /usr/lib/firefox/plugins and it picked it up.”
This might be useful for the non-idiots, but the newbies like me need to copypaste everything to the terminal, otherwise I’ll never figure out what to do. Somebody please help!
Hodge script works well. Thanks. There are more current snapshots at http://download.java.net/jdk6/, which seem to work though you have to take care to use the names of these builds and edit the script accordingly.
Please someone tell me how can I remove this? Doesn’t work with the ubuntuzilla firefox (I can’t seem to uninstall that either, only the ubuntuzilla program itself). I start to hate Ubuntu to be honest. Why do I need to be a hacker to make these basic things to work?
hey, you are genius. this the first time i ever succed installing java update since i used ubuntu desktop before 4 years.
realy thanks for the simple elegent and informative post
nebim
hey, you are genius. this the first time i ever succeed installing java update since i used ubuntu desktop before 4 years.
really thanks for the simple elegant and informative post
nebim
ONE THING IS MISSING…you NEED to create another ln -s link to the /usr/lib64/mozilla/plugins to get it work!
Hi,
Actually you only need to create the ln -s link to the /usr/lib64/mozilla/plugins if you want the plugin to be used system wide. If you’re the only user on the system, or you don’t want the changes system wide, creating the link to your home directory will suffice.
No way to let firefox 3.5.6 recognize the java plugin.
I am on ubuntu 9.10 64 bit .
Java works fine but firefox do not find the plugins…. I think 3.5.6 is the worst release ever …. also fonts are decreased …
Any suggestion?
Andrea
[...] Install Java JRE 1.6.0 (Update x) in Linux as the Default Java Runtime, including Firefox Browser Pl… (tags: linux debian ubuntu java sysadmin) Categories: Microblog Comments (0) Trackbacks (0) Leave a comment Trackback [...]
When I tested it using tester page after following all the steps detailed above , the browser closed if I use copy option for mozilla plugin but if I use link option ,it worked perfectly .
Hi,
A video from YouTube on how to install Java 6 on Ubuntu here.
Sunil.
Thank you for your precious and so clear help! After many crashes with other methods, eventually this time I succeeded installing Java 64 on my Ubuntu 9.10 64 with Firefox 3.6.
And it works!
For java installation on Fedora Linux, you can check this post
[...] I have found this article by another search: http://www.64bitjungle.com/ubuntu/install-java-jre-160-update-x-on-hardy-as-the-default-java-runtime… [...]
[...] en savoir plus sur l’utilisation & renseillement: Cliquer ici VERSION ENGLISH: Click here var a2a_config = a2a_config || {}; a2a_localize = { Share: "Partager", Save: "Enregistrer", [...]
sudo apt-get install ia32-libs
sudo apt-get install lib32nss-mdns
and try again installing jdk
Thanks Dude…!!! Its a grate Description i have ever seen on any website…!!!! Thanks for the Description.
This worked like a charm. Thank you.