For some years now, the following procedure is my favorite way for installing java on Ubuntu.
The following pages were my sources for installing Java
http://www.shinephp.com/install-jdk-7-on-ubuntu/
http://wiki.ubuntuusers.de/Java/Installation/Manuell
Download java
http://www.oracle.com/technetwork/java/javase/downloads
First extract the .tar.gz-file
Second move it to the correct directory
sudo mv ./jdk1.7.0_09/ /usr/lib/jvm/jdk1.7.0_09
It makes sense to add a symlink:
sudo ln -s /usr/lib/jvm/jdk1.7.0_09 /usr/lib/jvm/java-7-sun
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/bin/java 2 Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-6-sun/bin/java 63 auto mode 1 /usr/lib/jvm/java-6-sun/bin/java 63 manual mode 2 /usr/lib/jvm/java-7-sun/bin/java 1 manual mode sudo update-alternatives --config java java -version
When updating java, you just make an new java-7-sun – symlink to the new jdk-dir and it’s done.
There is also the compiler to install …:
sudo update-alternatives --config javac sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-sun/bin/javac 1 javac -version
… and Webstart:
sudo update-alternatives --config javaws sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/java-7-sun/bin/javaws 1
Close Firefox
sudo update-alternatives --install /usr/lib/mozilla/plugins/mozilla-javaplugin.so mozilla-javaplugin.so /usr/lib/jvm/java-7-sun/jre/lib/amd64/libnpjp2.so 1 sudo update-alternatives --config mozilla-javaplugin.so
Source: http://brunoreis.com/tech/intalling-java-ubuntu-natty/
sudo update-alternatives --config java
Updating of Java
Nowadays you have to update java quite often. A simple procedure is to copy the new java Version to /usr/lib/jvm and to update the symlink.
Download and extract the jdk-7uXX-linux-x64.tar.gz – File
tar -vxzf Downloads/jdk-7u17-linux-x64.tar.gz
Move the new jkd-directory to /usr/jvm/lib
sudo mv ./Downloads/jdk1.7.0_17/ /usr/lib/jvm/jdk1.7.0_17
Update the symlink
sudo ln -nsf /usr/lib/jvm/jdk1.7.0_17 /usr/lib/jvm/java-7-sun
Test the correct java – version
java -version java version "1.7.0_17" Java(TM) SE Runtime Environment (build 1.7.0_17-b02) Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
Restart Firefox
Delete the old jdk-directory
sudo rm -r /usr/lib/jvm/jdk1.7.0_13
Many thanks !
quick and painless.
virtual hug.
Worked perfectly, thanks!
Does this procedure automatically sets JAVA_HOME path?
no
how to set the class path for my programs ??????
You have to export the JAVA_HOME environment variable.
Edit .bashrc in your homedir to add the JAVA_HOME to your path, so it will work after a new login
further information is found here:
http://ubuntuforums.org/showthread.php?t=363461
Awesome, finally some instructions that work!
Awesome, exactly what I was looking for 🙂
Just one remark: you first have to ‘–install’ before you do the ‘–config’ 😉
Thank you, I will update it.
Thanks a lot 🙂
A million thanks! Worked like a charm in mint 15 (aside from having to sub in current jdk version, which was just plane easy).