Home > front end >  How to install jdk 8 on ubuntu server 18.04?
How to install jdk 8 on ubuntu server 18.04?

Time:02-07

I am trying to install JDK 8 ON Ubuntu server 18.04 LTS, with the following commands:

sudo apt install openjdk-8-jre
sudo apt install opemjdk-8-jdk

/usr/lib/jvm folder has: enter image description here

I also set the path into /etc/environment for JAVA_HOME But I still get an error while java -version as:

Command 'java' not found, but can be installed with:

sudo apt install default-jre            
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless 

Can anyone please suggest to solve an error? Thank you in advance.

CodePudding user response:

Update alternatives for Java. This should fix the problem:

 update-alternatives --config java

Reference: https://linoxide.com/install-java-ubuntu/

CodePudding user response:

try this one.

apt install oracle-java8-set-default

The above commands will automatically install selected java version and set all necessary java environment variables.

  •  Tags:  
  • Related