5

I installed Debian 8, I would like to install Java JRE and JDK. I use this method and it works.

But, I am afraid because it's a script hosted in a repository. I would like to understand why it doesn't work when I put the extract of this JRE in /usr/java/jre1.8.0_73 directory as per the documentation. I added the path variable with PATH=/usr/local/jdk1.8.0/bin:$PATH export PATH as explained in this doc but it doesn't work.

Even if I try to install OpenJDK, the package isn't found. I don't understand why it's so complicated to install Java on Debian; it is very simple on Ubuntu. I would like someone give me step-by-step instructions to install it.

6

You’ll find OpenJDK 8 in Jessie backports (thanks to Willian Paixao for reminding me):

echo deb http://http.debian.net/debian jessie-backports main > /etc/apt/sources.list.d/jessie-backports.list
apt update

will enable that, then

apt install -t jessie-backports openjdk-8-jdk

will install the JDK, or

apt install -t jessie-backports openjdk-8-jre

will install the JRE.

If you want Oracle’s JVM, see my answer to Linux Mint Petra (16) Java Update from JRE 7 to JRE 8 breaks Graphics System?, it’s quite simple too.

2

According to the official website you can build and install java as follows :

Add contrib to your /etc/apt/sources.list.

Download the jdk-8u121-linux-x64.tar.gz from oracle

Install the required package:

apt-get update
apt-get install 
apt-get install java-package

Build the .deb file then install it:

make-jpkg jdk-8u121-linux-x64.tar.gz
dpkg -i oracle-java8-jdk_8u121_amd64.deb

Run the following command then select jdk-8:

update-alternatives --config java

sample output:

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

Selection    Path                                            Priority   Status
------------------------------------------------------------
  0         /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      auto mode
  1         /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      manual mode
* 2         /usr/lib/jvm/jdk-8-oracle-x64/jre/bin/java       318       manual mode

Run : java -version

java version "1.8.0_121"
1

This method using PPA repositories are very unstable and frequently don't work out of Ubuntu's ecosystem. You better either install OpenJDK from Debian's official package repositories [1]. It's important to notice that by the time I write, Open JDK 8 is not included in the stable repository. Means you need to add backports to source.list before installing it via apt-get. [2]

I would rather download the Oracle tarball and simply extract it. Then as you mentioned, just append the /bin folder to $PATH and be happy.

  • 1
    Maybe even simpler than using the backports is just installing Debian 9. – Rui F Ribeiro Mar 9 '17 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy