Skip to content
Advertisement

What’s the correct way of installing jdk on linux

I am running the debian based Crunchbang linux system and i want to install the Oracle JDK (not openjdk) on my system.

I’ve spent some time to google for it, but i was not able to find a clear description of how to install (and configure) it. So here are my questions:

WHERE is the correct/best location to install the downloaded JDK? (most people prefer something like usr/lib/jvm. why?

when i have installed the jvm (i.e. copied the content of the jdk<version>.tar.gz file to the chosen location, i have to setup my system to refer to the jdk.

here I can use for example: sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk<version>/bin/java" 1. i have to do the same with javac right?

finally i have to set the JAVA_HOME variable by adding the lines:

JAVA_HOME=/usr/lib/jvm/jdk<version>/
export JAVA_HOME

to the .bashrc file.

But the problem: This way i always have to update my alternatives whenever i upgrade my jdk right? How can i solve this? Can anybody give a clear description how to install the jdk on linux systems in a clever and correct way?

thank you

Advertisement

Answer

You can install and stay up to date with the latest Oracle Java 7 and all you have to do is manually add the PPA repository to the Software Sources.

From http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html:

su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a     /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer
exit

For Ubuntu, http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html. With this, I’ve managed to installed JDK on my ubuntu server.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement