search all installed JDKs when java.home not specified#1701
search all installed JDKs when java.home not specified#1701fbricon merged 4 commits intoredhat-developer:masterfrom
Conversation
Signed-off-by: Yan Zhang <yanzh@microsoft.com>
|
https://github.com/redhat-developer/vscode-java#setting-the-jdk should also be updated in this PR. I'll do that after you review it. |
Signed-off-by: Yan Zhang <yanzh@microsoft.com>
Signed-off-by: Yan Zhang <yanzh@microsoft.com>
Signed-off-by: Yan Zhang <yanzh@microsoft.com>
|
Yes, feel free to merge. We can update release documents afterwards. |
|
I think there might be an issue with this change that ends up affecting Linux distros. Have a look at https://github.com/redhat-developer/vscode-java/blob/master/src/findJavaRuntimes.ts#L247 It's fairly common for symbolic links in /usr/lib/jvm of the form |
|
Exactly. Let me check if it's safe to simply remove the |
|
@rgrunber Is it a convention to install JDKs into |
|
The It was not intended to fix any edge case, and I just tried after removing it, no problems found. So I just created a PR to remove it. |
This can vary between distros, so I don't think it holds in call cases, but it could be a good fallback. It's certainly the case for Fedora and Ubuntu. |
|
@rgrunber ok, I can add |
In macOS Big Sur,
/usris wronly recongnized as JDK homedir. See #1700 (comment)It's caused by defect of upstream lib node-find-java-home. As a hotfix, here I copied a file from https://github.com/microsoft/vscode-java-pack/blob/fc6cb66f496fbbe5e8b2d9971c430e081f5b5460/src/java-runtime/utils/findJavaRuntime.ts
By validating all installed JDKs, this PR can also fix #1621
Now the JDK detection follows below order:
java.homeis specified, we validate it, and if it's invalid, we prompt error message as beforejava.homeis not specified, we search all possible places(env.JAVA_HOME, env.PATH, Windows Registry, Common installation directories for popular distributions) for installed JDKs, pick a valid one (major version >= 11) if exists