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

Global JDK Management Capability Support #3954

Open
tonycody opened this issue Feb 18, 2025 · 3 comments
Open

Global JDK Management Capability Support #3954

tonycody opened this issue Feb 18, 2025 · 3 comments
Labels

Comments

@tonycody
Copy link

tonycody commented Feb 18, 2025

Like when using JetBrains IDEA, the IDE provides the ability to manage JDKs globally, which allows developers to specify a uniform JDK version based on the set global JDKs regardless of what JetBrains plugin they are using, but in VSCode, each feature is supported as an extension, and each extension doesn't have a uniformly managed JDKs This is a headache for developers. Each extension has to set a JDK path, and there is no entry point that can be globally referenced. I'm not even sure what version of the JDK the extension is working with, and what version of the JDK is being used to compile the project. It's very confusing.

Image

@rgrunber
Copy link
Member

rgrunber commented Feb 18, 2025

Have you tried https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack ? It should have a way to nicely configure your project JDK : https://code.visualstudio.com/docs/java/java-project#_configure-runtime-for-projects .

If you have a managed project (eg. Maven, Gradle, Eclipse-based). then the build files (pom.xml, build.gradle, .classpath, etc) will specify what the supported compile/runtime is. vscode-java will scan your system, and attempt to find a compatible version. You can modify this using the setting java.configuration.runtimes (this is what the above extension does), which maps an execution environment (eg. JavaSE-11 to the JDK that should be used when that environment is requested (eg. ~/.sdkman/candidates/java/11.0.25-tem/). There's also a property to configure what should be the default JDK when dealing with unmanaged projects.

If by "extension" you mean contributions to VS Code like "vscode-java", then you shouldn't have to worry about their runtime. The extension provides its own JRE on most platforms. There is an option to override that (java.jdt.ls.java.home) but most users wouldn't need to.

@tonycody
Copy link
Author

Have you tried https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack ? It should have a way to nicely configure your project JDK : https://code.visualstudio.com/docs/java/java-project#_configure-runtime-for-projects .

If you have a managed project (eg. Maven, Gradle, Eclipse-based). then the build files (pom.xml, build.gradle, .classpath, etc) will specify what the supported compile/runtime is. vscode-java will scan your system, and attempt to find a compatible version. You can modify this using the setting (this is what the above extension does), which maps an execution environment (eg. to the JDK that should be used when that environment is requested (eg. ). There's also a property to configure what should be the default JDK when dealing with unmanaged projects.java.configuration.runtimes``JavaSE-11``~/.sdkman/candidates/java/11.0.25-tem/

If by "extension" you mean contributions to VS Code like "vscode-java", then you shouldn't have to worry about their runtime. The extension provides its own JRE on most platforms. There is an option to override that () but most users wouldn't need to.java.jdt.ls.java.home

I've used this configuration, but for some unknown reason it doesn't take effect in VSCode. In short, when developing with VSCode for Java, the choice of JDK is very unclear. I don't understand why everything is configured through settings.json instead of providing a UI for developers to select from. Isn't a UI experience much better? Who would know how to configure the JDK information without reading the documentation? Moreover, every developer's local environment is different and they all have to configure their JDK paths. Why can't it be like JetBrains, where you can download a JDK from their own marketplace? That way, at least the usage of the downloaded JDK would be unified.

I've spent a long time configuring the JDK for Java development in VSCode, and it still doesn't work well.

For example, the JDK used by the extension at runtime does not match the one used in my project. Even when I configure my project's JDK as the extension requires, it still doesn't take effect in the terminal. I can't figure out why.

Currently, the barrier to entry is too high. There are too many hidden details that require developers to be very familiar with the extension's configuration. It takes a long time to sort out all these configuration relationships.

@tonycody
Copy link
Author

Image

Image

I think that when configuring the Project Settings, if the user updates the JDK Runtime and simultaneously adjusts the environment configuration in the Terminal, it can resolve the issue of an inconsistent JDK.

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

No branches or pull requests

2 participants