How to install java 8 on Ubuntu 19.04?

Asked

Viewed 625 times

-1

First of all, I know it seems a rather silly question, but I am a Windows "user", I have the dual boot on my machine.I really admire Unix, and I intend to migrate to it for good.

I was using Ubuntu 18 but I formatted the machine and installed Ubuntu 19. In this I installed our beloved java, but I installed in a hurry and unintentionally installed java 11. I tried to remove it and install java 8 but was unsuccessful.

When I gave command java -version: obtained.

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)

Since I want to develop applications with React-Native and need to use java 8 instead of more current.

How do I install it? Has anyone been through this? When I try to install java8 , as an answer I am informed that it is no longer in repositio.

I tried to this tutorial but nothing.

  • 1

    First, remove openjdk in version 11. sudo rm -rf /usr/lib/jvm/openjdk* Manually install. Download version 8 on the Oracle website, extract, put it in /usr/lib/jvm and be happy.

1 answer

0


If you used the apt to install:

The first step is to uninstall older versions.

sudo apt remove openjdk-11*

This will cause apt to search for any package that contains "openjdk-11" installed, and then remove it. Then, just use

sudo apt install openjdk-8-jdk

You may need to download the openjdk-8-jre package as well.


If you installed manually:

Remove openjdk in version 11.

sudo rm -rf /usr/lib/jvm/openjdk*

Next, download on the Oracle website the JDK 8 (necessary to login, but it is quick thing). Extract your content in /usr/lib/jvm/ and you already have the JDK 8 on your machine.

In both versions you need to export your environment variables from Java.

For this, edit the file /etc/profile:

$ sudo nano /etc/profile

Add lines:

JAVA_HOME=/usr/lib/jvm/nome-da-pasta-do-seu-jdk/ 
PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME
CLASSPATH=$JAVA_HOME/lib/tools.jar 
CLASSPATH=.:$CLASSPATH 
export  JAVA_HOME  PATH  CLASSPATH

Restart the computer and check if everything is right using the command

java -version


Reference

Browser other questions tagged

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