2

I'm having trouble changing the default version of Java on Ubuntu 20.10.

I want to change the default version of Java JDK from Graal to OpenJDK 13.

I start by checking the default version:

$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

I change the version as follows, selecting OpenJDK version 13:

$ sudo update-alternatives --config java
There are 4 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-13-openjdk-amd64/bin/java      1211      auto mode
  1            /usr/lib/jvm/graalvm/bin/java                    4         manual mode
  2            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
* 3            /usr/lib/jvm/java-13-openjdk-amd64/bin/java      1211      manual mode
  4            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press <enter> to keep the current choice[*], or type selection number: 3

If I check version again it's still saying the version is GraalVM:

$ java -version
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)
$ 

I've restarted my machine, but the GraalVM is still the default.

Why is the version not changing? What am I missing?

3

I figured out the ~/.bashrc and noticed that I'd added a path to the Graal /bin folder to the PATH.

Once I removed that, I opened a new terminal, re-ran the update-alternatives, and saw that the version was set properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.