Sunday, November 13, 2016
How to install java 8 in Debian Jessie from Oracle website
Hi all,
Sometimes it's necessary to install newer version of java that there is in official Debian Jessie repository. In that case you need to download it from oracle website, extract files and update links to java executables. It can be done via update-alternatives or simply by replacing links (which is not recommended). Below I will show you both methods.
1) create install folder and navigate to it:
2) download jdk 1.8. The tricky part here is that you need to accept license agreement by passing a cookie:
3) extract files from archive:
4) Install alternative for each java executable that you need to use. In this example we will install 3 alternatives for: java, javac, jar (but you may also install more than just 3):
5) Configure alternatives:
1) Download jdk and extract files as described in 1.1-1.3.
2) update links to point to java 1.8 (you may need to backup original files):
If you don't need java compilers, then you can only download jre.
1) Download jre and extract files as described in 1.1-1.3.
2) update links to point to java 1.8 (you may need to backup original files):
That's it. After completing these steps using either 1st or 2nd method you should have working java 8 on your Debian Jessie machine. To check current java version use this command:
You can also watch this tutorial:
Sometimes it's necessary to install newer version of java that there is in official Debian Jessie repository. In that case you need to download it from oracle website, extract files and update links to java executables. It can be done via update-alternatives or simply by replacing links (which is not recommended). Below I will show you both methods.
1) Update-alternatives way
1) create install folder and navigate to it:
mkdir ~/install cd ~/install
2) download jdk 1.8. The tricky part here is that you need to accept license agreement by passing a cookie:
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u73-b02/jdk-8u73-linux-x64.tar.gz
3) extract files from archive:
tar -xvzf jdk-8u73-linux-x64.tar.gz
4) Install alternative for each java executable that you need to use. In this example we will install 3 alternatives for: java, javac, jar (but you may also install more than just 3):
sudo update-alternatives --install /usr/bin/java java ~/install/jdk1.8.0_73/bin/java 1000 sudo update-alternatives --install /usr/bin/javac javac ~/install/jdk1.8.0_73/bin/javac 1000 sudo update-alternatives --install /usr/bin/jar jar ~/install/jdk1.8.0_73/bin/jar 1000The last number in the command is the priority which is used in auto-mode only, where program with the highest priority is used as default. If you want to understand the difference between manual and auto modes, I recommend watching this video.
5) Configure alternatives:
sudo update-alternatives --config java sudo update-alternatives --config javac sudo update-alternatives --config jarAfter running each command, change the selection by entering a number, which is manual mode of particular executable in jdk1.8.
2) Manual way (not recommended)
2.1) jdk 1.8
1) Download jdk and extract files as described in 1.1-1.3.
2) update links to point to java 1.8 (you may need to backup original files):
sudo ln -sf ~/install/jdk1.8.0_73/bin/jar /usr/bin/jar sudo ln -sf ~/install/jdk1.8.0_73/bin/javac /usr/bin/javac sudo ln -sf ~/install/jdk1.8.0_73/bin/java /usr/bin/java #sometimes you may need to update default-java sudo mkdir -p /usr/lib/jvm sudo rm /usr/lib/jvm/default-java sudo ln -s ~/install/jdk1.8.0_73/bin/java /usr/lib/jvm/default-java
2.2) jre 1.8
If you don't need java compilers, then you can only download jre.
1) Download jre and extract files as described in 1.1-1.3.
2) update links to point to java 1.8 (you may need to backup original files):
sudo ln -sf ~/install/jre1.8.0_73/bin/java /usr/bin/java #sometimes you may need to update default-java sudo mkdir -p /usr/lib/jvm sudo rm /usr/lib/jvm/default-java sudo ln -s ~/install/jre1.8.0_73/bin/java /usr/lib/jvm/default-java
The end
That's it. After completing these steps using either 1st or 2nd method you should have working java 8 on your Debian Jessie machine. To check current java version use this command:
java -versionwhich should return something like this:
java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
You can also watch this tutorial:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment