skip to Main Content

I set JAVA_HOME in .bashrc on my Ubuntu 22.04.2 LTS system, but when I check the version, it’s still the old one:

ruomini@ruomini-XPS-13-9370:~$ echo $JAVA_HOME
/home/ruomini/jdk-17.0.7
ruomini@ruomini-XPS-13-9370:~$ java -version
openjdk version "11.0.18" 2023-01-17
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.04)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.04, mixed 
mode, sharing)
ruomini@ruomini-XPS-13-9370:~$ 

2

Answers


  1. execute the source command /etc/profile

    Login or Signup to reply.
  2. In Ubuntu you can run

    update-alternatives --list java

    then you will get a listing of properly installed JDKs/JREs the operating system knows about.

    /usr/lib/jvm/java-11-openjdk-amd64/bin/java
    /usr/lib/jvm/java-7-oracle/jre/bin/java
    /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
    

    then run
    update-alternatives --set <one of the list items> to switch to a different one.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search