Linux, Windows, Virtualization, OpenSource & Blogging

How to Install Oracle JAVA 8 on Debian 9 / Debian 8

0

 

Today we will be going through the installation of Oracle Java SDK 1.8_u144 on Debian 9. Java SDK is the most important one for the developers, and this guide will be more useful for them to build development environment when they especially use Debian.

Download Java SDK

You can download JDK using either command line or browser to download.  Better to use the browser, the easiest way to download Oracle SDK.

Want to download Oracle Java 8 on the terminal, run:

### 32 bit ###

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-i586.tar.gz

### 64 Bit ###

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz

Extract the downloaded JDK archive to the desired directory (Ex. /usr/)

# tar -zxvf jdk-8u*-linux-*.tar.gz

#  mv jdk1.8.*/ /usr/

Install Oracle Java 8

Once you moved the java to the location you want, then you must run update-alternatives commands to install the Java on your system.

# update-alternatives --install /usr/bin/java java /usr/jdk1.8.*/bin/java 2

# update-alternatives --config java

Select the Oracle Java

If the system has multiple versions of JAVA, then the above command may list it all, like below.

There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      auto mode
  1            /usr/jdk1.8.0_144/bin/java                       1         manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode
  3            /usr/lib/jvm/java-9-openjdk-amd64/bin/java       1091      manual mode

Press  to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/jdk1.8.0_144/bin/java to provide /usr/bin/java (java) in manual mode

Verify the Java

Once you have set up the alternatives then check the java version using the following command.

# java –version

Output:

java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)

Setup Environmental Variable

Some Java application installations require prior configuration of environmental variables like JAVA_HOME, JRE_HOME, etc. So, you can set the environmental varaiables like below.

# export JAVA_HOME=/usr/jdk1.8.0_*

# export JRE_HOME=/usr/jdk1.8.0_*/jre/

Set PATH variable too.

# export PATH=$JAVA_HOME/bin:$PATH

To set it as a permanent, place the above commands in the “/etc/profile” (All Users) or “~/.bash_profile ” (Single User) file.

That’s All!. Hope this post helped you to install Oracle Java on Debian 9.

You might also like
Shares