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
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.