Install JDK 8, 9 or 10 on Ubuntu 18.04

Asked

Viewed 5,363 times

1

Does anyone know another way to install java in Ubuntu 18.04.

I tried java 8 and 10 and gave these errors:

"The oracle-java10-installer package is not available, but is referenced by another package. This may mean that the package is missing, has become obsolete or is only available from another source

E: The oracle-java10-installer package has no installation candidate"

"The oracle-java8-installer package is not available, but is referenced by another package. This may mean that the package is missing, has become obsolete or is only available from another source"

  • Go to your terminal and type: sudo apt-get install oracle-java8-installer

  • You can install the default-jdk that is Openjdk. Doesn’t it solve? I believe that, nowadays, to install Oracle tools, only creating an account on the Oracle site and downloading directly from them.

1 answer

1


Install Oracle’s Java 8

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer

Check the installed version

Leave version 8 as default

$ sudo apt-get install oracle-java8-set-default
$ java -version

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Configure the environment variables

cat >> /etc/environment <<EOL
JAVA_HOME=/usr/lib/jvm/java-8-oracle
JRE_HOME=/usr/lib/jvm/java-8-oracle/jre
EOL

Alternative option with openjdk

$ sudo add-apt-repository ppa:openjdk-r/ppa
$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk
  • I tried this way and occurred the errors I said

  • you tried to give a sudo apt update before doing the sudo apt install oracle-java8-installer?

  • yes, I tried but it didn’t work out

  • @Leandro tries the alternative option with openjdk

  • Voce knows if there is much difference between oracle jdk and openjdk?

  • not much difference, I always used openjdk and never gave problem, develop for android using this java installed

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.