Why won't sdkman change my default java version?
Asked Answered
C

2

8

This problem persisted after updating and upgrading sdkman, deleting .sdkman and reinstalling it, and uninstalling java packages and reinstalling them.

me@myMachine myProject $ sdk default java 8.0.252.hs-adpt
Default java version set to 8.0.252.hs-adpt
me@myMachine myProject $ sdk default java
Default java version set to 11.0.7.hs-adpt

sdk current java and java -version reflect the change but reverts back to 11.0.7 upon closing and reopening terminal, or opening a different window or app.

Chickenlivered answered 9/7, 2020 at 14:7 Comment(0)
H
5

I just happen to get that error, on Manjaro ..after an update of the S.O., so the error is the /usr/bin/java now points to the default java installed on the update.

So i just removed all Java versions installed on the updates cause I need only to use the sdkman.

sdk home java 8.0.232.hs-adpt

With this i can see where are the candidates on my case:

/home/xxxx/.sdkman/candidates/java/8.0.232.hs-adpt

So after removed all java: i run java -version i found there is no java anymore.

So i force update sdkman

sdk selfupdate force

Then after install

source "$HOME/.sdkman/bin/sdkman-init.sh"

And to be sure i ran :

ls -al /usr/bin/java

lrwxrwxrwx 1 root root 37 may 16 2020 /usr/bin/java -> /usr/lib/jvm/default-runtime/bin/java

and now it points to where sdkman supposed to:

And thats it now i can change versions again with sdkman.

sdk use java 11.0.5.hs-adpt
Hardee answered 14/4, 2021 at 2:3 Comment(1)
Yes. This is on the right path. In my case, I had installed Java via Homebrew prior to starting to use sdkman so I needed to uninstall with brew uninstall java first and then immediately afterwards, java -version and which java was correctly showing the Java version from sdkman. Thanks.Flacon
R
1

For me, the problem was the ending of .bashrc. I know, it explicitly says there "THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!", but I still decided to ignore that and wrote a few of my own lines after those ones 🤡. When I made sure the sdkman's lines were indeed at the very end of the file and after running sdk selfupdate force, setting the version started working properly across different terminals.

Ruphina answered 22/4 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.