What is the correct way to install jdk on linux

I am running a debian-based Linux system Crunchbang and I want to install Oracle JDK (not openjdk) on my system.

I spent some time on Google, but I could not find a clear description of how to install it (and configure it). So here are my questions:

Where is the right / best place to install the downloaded JDK? (most people prefer something like usr/lib/jvm . Why?

when I installed jvm (i.e. copied the contents of the jdk<version>.tar.gz file to the selected location, I need to configure my system to link to jdk.

here I can use, for example: sudo update-alternatives --install "/usr/bin/java" "java" \ "/usr/lib/jvm/jdk<version>/bin/java" 1 . should i 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 .

But the problem is: in this way should I always update my alternatives when I update my jdk correctly? How can i solve this? Can someone give a clear description of how to install jdk on Linux systems in a smart and proper way?

Thank you

+8
java linux
source share
3 answers

You can install and stay up to date with the latest versions of Oracle Java 7, and all you need 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 . In doing so, I was able to install the JDK on my ubuntu server.

+9
source share

Step 1: Open the application → Accessories → Terminal

Step 2: Enter the command line as shown below ...

  sudo apt-get install openjdk-6-jdk 

Step 3: Enter the command line as shown below ...

  apt-cache search jdk 

(Note: openjdk-6-jdk is symbolically used here, you can choose the jdk version according to your requirement.)

How to set "Environment Variables" for "Open jdk" on Ubuntu (Linux)?

Step 4: For a command of type "JAVA_HOME" (Environment Variable), as shown below, in the "Terminal" using the installation path ...

  export JAVA_HOME=/usr/lib/jvm/java-6-openjdk 

(Note: "/ usr / lib / jvm / java-6-openjdk" is symbolically used here just for demonstration, you should use your path as per your installation.)

Step 5: For a command of type "PATH" (Environment Variable), as shown below, in the "Terminal" using the installation path ...

  export PATH=/usr/lib/jvm/java-6-openjdk/bin 

(Note: "/ usr / lib / jvm / java-6-openjdk" is symbolically used here just for demonstration, you should use your path as per your installation.)

Step 6: Verify the installation of "open jdk", just enter the command in the "Terminal" as shown below java

+3
source share

Just create a symlink /usr/lib/jvm/jdk that points to /usr/lib/jvm/jdk<version> . Then, all you have to do after updating the JDK is updating the symlink to point to the new location.

+2
source share

All Articles