Closed mamilic closed 1 week ago
The auto detection is done by https://github.com/Eskibear/node-jdk-utils#readme . The setting java.configuration.runtimes
should allow you to manually configure JDKs though. See https://github.com/redhat-developer/vscode-java/wiki/JDK-Requirements#project-jdks . The way it works with Gradle (or even Maven) is that the build files (build.gradle, pom.xml) would assert a specific source/target/release version of the JDK (eg. 11) and vscode-java will look for a configured JDK that suports that (eg. JavaSE-11). If none can be found, it looks like our auto detection tries to configure an existing JDK to the environment (eg. source/target = 19
-> JavaSE-19
-> /path/to/some/detected/jdk-23/
). If you have https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack , this actually has a UI menu, "Project Settings" that allows you to configure these compiler options.
There is code in the language server to help users when the Gradle version is not compatible with a chosen JDK, https://github.com/eclipse-jdtls/eclipse.jdt.ls/blob/ba8d0910917bab70b8565af15d7960c2e1ae8058/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/managers/GradleUtils.java#L83-L120 .
Let me know if there's anything about this that doesn't work as you expect.
@rgrunber , thanks a lot! Did not know that configuration already exist. This issue can be closed.
We should do a better job at advertising the various options : https://github.com/redhat-developer/vscode-java?tab=readme-ov-file#supported-vs-code-settings . There's quite a lot there.
Would it be possible to allow users to set or modify the "Project Java SDK" in VS Code? Currently, it seems to be auto-detected. This proposed setting would allow users to select from a dropdown of detected SDKs, with an option to include manually configured SDKs.
Scope and Application: The configured SDK setting would be applied across all relevant Java-related components within VS Code, such as:
This setting would primarily impact runtime configurations. For example:
Thank you for considering this feature. It would provide users with more flexibility in managing their development environment and streamline project compatibility across different Java SDK versions.