Skip to content

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:

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



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.


su -
echo "deb precise main" | tee -a     /etc/apt/sources.list
echo "deb-src precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer

For Ubuntu, 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