jMan
jMan

Reputation: 637

Why won't sdkman change my default java version?

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.

Upvotes: 8

Views: 19406

Answers (2)

DL33
DL33

Reputation: 204

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.

Upvotes: 1

cabaji99
cabaji99

Reputation: 1445

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

Upvotes: 5

Related Questions