Home > Software design >  How can I change Java version 1.7 to 1.8 in Ubuntu?
How can I change Java version 1.7 to 1.8 in Ubuntu?

Time:11-14

My Ubuntu machine have installed both java 1.7 and 1.8. But when I checked Java version it shows version Java 1.7 as the snapshot below. When I check Java alternative version I can see "java-8-openjdk-amd64". I am beginner to Ubuntu. Can anyone help me to change it to 1.8?

enter image description here

CodePudding user response:

sdkman is a good Open source version manager for Java. It provides commands to search & install multiple versions of Java and switch between versions with

sdk use java 1.8.363-open

It can also manage other tools like Maven.

CodePudding user response:

you can set the envirnoment variable to java 1.8 using this method Edit the /etc/profile

    sudo gedit /etc/profile

Add these lines in the end

    JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    export JAVA_HOME
    export JRE_HOME
    export PATH

like mentioned in this answer

How to set Java environment path in Ubuntu

  • Related