Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a default JVM version in Windows isn't working #2956

Open
andrelfpinto opened this issue Apr 3, 2024 · 0 comments
Open

Setting a default JVM version in Windows isn't working #2956

andrelfpinto opened this issue Apr 3, 2024 · 0 comments

Comments

@andrelfpinto
Copy link
Contributor

If I setup multiple default JVM versions as:

> cs java --jvm adoptium:1.17.0.10 --setup
Checking if the JAVA_HOME, PATH user environment variable(s) need(s) updating.
Some global environment variables were updated. It is recommended to close this terminal once the setup command is done, and open a new one for the changes to be taken into account.
> cs java --jvm adoptium:1.17 --setup
Checking if the JAVA_HOME, PATH user environment variable(s) need(s) updating.
Some global environment variables were updated. It is recommended to close this terminal once the setup command is done, and open a new one for the changes to be taken into account.
> cs java --jvm adoptium:1.11.0.22 --setup
Checking if the JAVA_HOME, PATH user environment variable(s) need(s) updating.
Some global environment variables were updated. It is recommended to close this terminal once the setup command is done, and open a new one for the changes to be taken into account.

The Java home environment variable is correctly set to the last one (Java 11):

> echo $Env:JAVA_HOME
C:\Users\user\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin11-binaries\releases\download\jdk-11.0.22%252B7\OpenJDK11U-jdk_x64_windows_hotspot_11.0.22_7.zip\jdk-11.0.22+7

But the one that is called is the first one (Java 17):

> java -version
openjdk version "17.0.10" 2024-01-16
OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)
OpenJDK 64-Bit Server VM Temurin-17.0.10+7 (build 17.0.10+7, mixed mode, sharing)

The problem is that the paths are aggregated and the first one takes precedence:

> echo $Env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Windows\Microsoft.NET\Framework\v4.0.30319;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Local\Coursier\data\bin;;C:\Users\user\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin17-binaries\releases\download\jdk-17.0.10%252B7\OpenJDK17U-jdk_x64_windows_hotspot_17.0.10_7.zip\jdk-17.0.10+7\bin;C:\Users\user\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin17-binaries\releases\download\jdk-17%252B35\OpenJDK17-jdk_x64_windows_hotspot_17_35.zip\jdk-17+35\bin;C:\Users\user\AppData\Local\Coursier\cache\arc\https\github.com\adoptium\temurin11-binaries\releases\download\jdk-11.0.22%252B7\OpenJDK11U-jdk_x64_windows_hotspot_11.0.22_7.zip\jdk-11.0.22+7\bin

Maybe, instead of aggregating, we should just add once %JAVA_HOME%/bin. Whenever JAVA_HOME changes, the path will too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant