Reputation: 51
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:~$
Upvotes: 4
Views: 2964
Reputation: 775
You may need to re-source sdkman-init:
source ~/.sdkman/bin/sdkman-init.sh
When I was in your situation, just after "installing" local versions to sdkman, use
worked, but list
and current
didn't show the local versions and env init
didn't populate .sdkmanrc with the version I selected with use
. Re-sourcing sdkman-init fixed these issues.
Posting for posterity.
Upvotes: 2
Reputation: 51
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.
Upvotes: 1