Search code examples
sdkman

sdkman! How to manage pre-existing JDK?


I wanted to try Java 19 and have easy switching back to the Java 17 that I have already installed.

So, I installed sdkman but it knows nothing of the previous Java. Found the "install local" command, used it to link the java 17 location to a unique name and sdkman seems happy, as it reports "Done installing!".

After that the "sdk current java" returns "Not using any version of java". So then I tried "sdk use java [my unique name]. That was also accepted. But still the "sdk current java" response is unchanged.

Have I misunderstood how this should work? I want to be sure sdkman knows what is there already before I add another Java.

Thanks for your advice!

Terminal commands follow (Kubuntu 22.04)

john@NUC8i3BEH:~$ java -version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM (build 17.0.4.1+1-LTS, mixed mode, sharing)
john@NUC8i3BEH:~$ sdk install java 17.0.4.1-Bellsoft /usr/lib/jvm/bellsoft-java17-full-amd64
Invalid version! 17.0.4.1-Bellsoft with length 17 exceeds max of 15!
john@NUC8i3BEH:~$ sdk install java 17.0.4.1-Bell /usr/lib/jvm/bellsoft-java17-full-amd64
Linking java 17.0.4.1-Bell to /usr/lib/jvm/bellsoft-java17-full-amd64
Done installing!

john@NUC8i3BEH:~$ sdk list
john@NUC8i3BEH:~$ sdk current

No candidates are in use
john@NUC8i3BEH:~$ sdk current java

Not using any version of java
john@NUC8i3BEH:~$ sdk list java
john@NUC8i3BEH:~$ sdk use java 17.0.4.1-Bell
==== BROADCAST =================================================================
* 2022-09-21: neo4jmigrations 1.12.0 available on SDKMAN! https://github.com/michael-simons/neo4j-migrations/releases/tag/1.12.0
* 2022-09-21: micronaut 3.7.0 available on SDKMAN!
* 2022-09-20: quarkus 2.12.3.Final available on SDKMAN! https://github.com/quarkusio/quarkus/releases/tag/2.12.3.Final
================================================================================
Setting java version 17.0.4.1-Bell as default.

Using java version 17.0.4.1-Bell in this shell.
john@NUC8i3BEH:~$ java -version
openjdk version "17.0.4.1" 2022-08-12 LTS
OpenJDK Runtime Environment (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM (build 17.0.4.1+1-LTS, mixed mode, sharing)
john@NUC8i3BEH:~$ sdk current java

Not using any version of java
john@NUC8i3BEH:~$

Solution

  • OK, I should have tried harder. I installed Java 19 with sdkman then the command "sdk default java [my old version]" switches back as required.