Open siakhooi opened 1 year ago
sdk upgrade java
will always download the default version set in sdkman. In this case, the default vendor is temurin
and the default version as of today is 17.0.4
. However, when sdkman asks about Do you want java 11.0.16-sapmchn to be set as default? (Y/n):
means the default version in your terminal at the local machine.
@eddumelendez same here and even this set as default
option doesn't work for me. It doesn't let me change the default java
version and the only version it accepts is 17.0.5-tem
. I have tried to make the 19-oracle
default version but it didn't work.
Edit: Weird thing is that default version command shows nothing but I can see that 19-oracle
is linked to the current one.
[28-11-2022 18:00:05] λ ~ sdk default java
Stop! Candidate version is not installed.
Tip: Run the following to install this version
$ sdk install java 17.0.5-tem
[28-11-2022 18:00:38] λ ~ ls -la .sdkman/candidates/java/
total 0
drwxr-xr-x 4 gg staff 128 28 Nov 16:50 .
drwxr-xr-x 3 gg staff 96 28 Nov 16:15 ..
drwxr-xr-x 12 gg staff 384 13 Aug 00:07 19-oracle
lrwxr-xr-x 1 gg staff 9 28 Nov 16:50 current -> 19-oracle
[28-11-2022 18:01:22] λ ~ java -version
java version "19" 2022-09-20
Java(TM) SE Runtime Environment (build 19+36-2238)
Java HotSpot(TM) 64-Bit Server VM (build 19+36-2238, mixed mode, sharing)
[28-11-2022 18:02:06] λ ~ which java
/Users/gg/.sdkman/candidates/java/current/bin/java
sdk upgrade java
will always download the default version set in sdkman. In this case, the default vendor istemurin
and the default version as of today is17.0.4
. However, when sdkman asks aboutDo you want java 11.0.16-sapmchn to be set as default? (Y/n):
means the default version in your terminal at the local machine.
I'm a bit confused. Do you mean that when installing SDKMAN we don't have the choice but to have the temurin 17.0.X SDK by default ? If so, why not allowing us to change it ?
It's a bit annoying because I do not use this version at all and each time start my shell I have the warning message Stop! java 17.0.5-tem is not installed.
If I set my default version using sdk default java XXXX
and restart the shell I get the same message again :/
Another strange behavior when setting sdkman_auto_env=true
:
I set default java version with sdk default java XXXX
then I cd
directory using a different java version --> I get a correct message from SDKMAN Using java version YYYY in this shell.
Now if I cd
out of the directory (cd ..
), SDKMAN tries to go back to the default version and I get the message No default version of java was found
even though I had just set it previously!
My guess is sdk default
command does not work, or at least not as I'm expecting it to work.
Please read the docs https://sdkman.io/usage#env
I obviously did otherwise I wouldn't know about sdkman_auto_env
. I've also read this:
Do you want to switch SDK versions automatically when you cd into a directory? This can be done by setting the sdkman_auto_env=true in the SDKMAN configuration. Note that this will also reset any project-specific SDKs to their default version when leaving the directory.
And this:
Default Version Chose to make a given version the default: $ sdk default scala 3.2.2 This will ensure that all subsequent shells will start with version 3.2.2 in use.
So either the documentation is wrong / unclear or there is bug. It would be nice if you can clarify.
Hi @mikymigs, there might be a third scenario, which use that it could be an environmental issue on your machine. Since nobody else has this issue, and all our test suites are green, I think this might be what you are seeing.
It is very difficult to figure out what the issue is if we know nothing about your environment. Please tell us what OS, shell, and all relevant versions of each you are using. Then we might be able to help.
Hello @marc0der, Thank you for your reply. I had not yet thought about the environmental issue because I wasn't sure of the intended behavior (some forum messages mislead me). Now that I know that setting a default version is supposed to be a working feature, the environmental factor is definitely first in line. I have done some tests in a linux VM and I can confirm it is working as documented. The issue seems to be linked to using Git Bash under windows. Not sure why but I'm not too surprised since Git Bash is a bit of a hack...
Thanks for the extra info @mikymigs. I've recently begun some work around Git Bash for Windows compatibility, so hopefully, things will improve. One of the issues is that MSYS does not provide first-class support for symlinks, a feature we rely upon heavily to set the current default version. Hopefully, we can get this working soon, but in the meanwhile, I'd suggest installing WSL as this provides seamless Linux integration for all the commands we provide.
Thank you the detailed reply @marc0der, this is excellent news. I hope you'll find a good solution regarding the symlinks. I tried making SDKMAN work under my current WSL install without re-installing it. I just added the SDKMAN config to .bashrc while re-routing the path to the host install path:
export HOST_HOME="/mnt/c/Users/mikymigs"
export SDKMAN_DIR="$HOST_HOME/.sdkman"
[[ -s "$HOST_HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOST_HOME/.sdkman/bin/sdkman-init.sh"
This seemed to work, so then I've tried setting the default version from the WSL terminal and it worked. The behavior is the expected one (cd to project directory, then cd out of project directory restores default version). But to my surprise, doing this in WSL made it also work in Git Bash! Not sure why but I guess I've found a good workaround by accident ;-)
@marc0der Hello, thank you for your explanation. I have the same problem using Debian inside WSL2, and I can't figure it out how to solve this problem. I have this:
$ sdk upgrade java
Available defaults:
java (local: 20-open, 17-open; default: 21.0.1-tem)
Use prescribed default version(s)? (Y/n):
I don't use temurin and don't want to install it. Can I update java installations somehow without installing it? As you can see I have only these version installed and I defaulted to 17-open.
$ ls -la .sdkman/candidates/java/
total 16
drwxr-xr-x 4 nikita nikita 4096 Nov 22 13:26 .
drwxr-xr-x 4 nikita nikita 4096 Apr 19 2023 ..
drwxr-xr-x 8 nikita nikita 4096 Apr 20 2023 17-open
drwxr-xr-x 8 nikita nikita 4096 Apr 19 2023 20-open
lrwxrwxrwx 1 nikita nikita 7 Nov 22 13:26 current -> 17-open
@Niks218 not yet, for now you explicitly need to install the version and distribution that you require.
Incidentally, Temurin is the industry accepted official OpenJDK distribution hosted by the Eclipse Foundation, which is why we advise it as the default.
Yes, but I explicitly installed 17-open and now it's required to install another distribution just to upgrade existing? I'm confused
$ sdk install java 11.0.16-sapmchn
Downloading: java 11.0.16-sapmchn
In progress...
##################################################################################################################################################### 100.0%
Repackaging Java 11.0.16-sapmchn...
Done repackaging...
Installing: java 11.0.16-sapmchn Done installing!
Do you want java 11.0.16-sapmchn to be set as default? (Y/n): Y
Setting java 11.0.16-sapmchn as default.
$ sdk upgrade java
Available defaults: java (local: 11.0.16-ms, 11.0.16-sapmchn; default: 17.0.4-tem)
Use prescribed default version(s)? (Y/n): n $