redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.07k stars 433 forks source link

Compiler issues #3747

Closed Carson-yy closed 3 weeks ago

Carson-yy commented 1 month ago

image

How can the above settings be configured to be enabled by default for all projects?

rgrunber commented 3 weeks ago

It depends what kind of build tool your project uses. A quick look shows the following for Maven & Gradle :

https://www.baeldung.com/maven-java-version https://docs.gradle.org/current/userguide/building_java_projects.html#sec:compiling_with_release

These would be set in your project configuration files, and vscode-java would respect those settings, assuming you had a compatible JDK on the local system.

For unmanaged projects, you could use the java.configuration.runtimes setting to target a particular Java version :

"java.configuration.runtimes": [
        {
            "name": "JavaSE-11",
            "path": "/usr/lib/jvm/java-11-opendjk/",
            "default": true
        }
],
...
...

(the "default": true would apply to the unmanaged project)

Carson-yy commented 3 weeks ago

It depends what kind of build tool your project uses. A quick look shows the following for Maven & Gradle :

https://www.baeldung.com/maven-java-version https://docs.gradle.org/current/userguide/building_java_projects.html#sec:compiling_with_release

These would be set in your project configuration files, and vscode-java would respect those settings, assuming you had a compatible JDK on the local system.

For unmanaged projects, you could use the setting to target a particular Java version :java.configuration.runtimes

"java.configuration.runtimes": [
        {
            "name": "JavaSE-11",
            "path": "/usr/lib/jvm/java-11-opendjk/",
            "default": true
        }
],
...
...

(the would apply to the unmanaged project)"default": true

OK,Thanks