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

Gradle does not seem to use $JAVA_HOME #1630

Open
sei-eschwartz opened this issue Nov 13, 2024 · 0 comments
Open

Gradle does not seem to use $JAVA_HOME #1630

sei-eschwartz opened this issue Nov 13, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sei-eschwartz
Copy link

sei-eschwartz commented Nov 13, 2024

Extension Name: vscode-gradle
Extension Version: 3.16.4
OS Version: Ubuntu 22.04.5 LTS
VSCode version: 1.95.2

Describe the bug

I have the JAVA_HOME variable set to the Temurin 21 JDK: /usr/lib/jvm/temurin-21-jdk-amd64. I expected that Gradle would do something sensible like use this as the default unless I configure otherwise.

But this does not seem to be what happens.

If I create a dummy build.gradle file containing:

task printJavaHome {
    doLast {
        println "Java Home: ${System.getProperty('java.home')}"
    }
}

And then I run this from VS code, I get:

> Task :printJavaHome
Java Home: /home/ed/.vscode/extensions/redhat.java-1.36.0-linux-x64/jre/17.0.13-linux-x86_64

Not what I was expecting!

Even if I set "java.jdt.ls.java.home": "/usr/lib/jvm/temurin-21-jdk-amd64", this is ignored. It is only if I set "java.import.gradle.java.home": "/usr/lib/jvm/temurin-21-jdk-amd64", that my JDK is used.

To Reproduce
Set $JAVA_HOME, create dummy gradle project as above.

Expected behavior
I expected $JAVA_HOME to be used as a reasonable default.

Output from "Gradle for Java"
You can find this by clicking on the "Output" panel, then selecting the "Gradle for Java" channel from the dropdown.

[info] [gradle-server] Gradle Server started, listening on 45455
[info] Gradle client connected to server
[info] Java Home: /home/ed/.vscode/extensions/redhat.java-1.36.0-linux-x64/jre/17.0.13-linux-x86_64
[info] JVM Args: --add-opens=java.base/java.util=ALL-UNNAMED,--add-opens=java.base/java.lang=ALL-UNNAMED,--add-opens=java.base/java.lang.invoke=ALL-UNNAMED,--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens=java.base/java.nio.charset=ALL-UNNAMED,--add-opens=java.base/java.net=ALL-UNNAMED,--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=384m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant
[info] Gradle User Home: /home/ed/.gradle
[info] Gradle Version: 8.8
[info] Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to https://docs.gradle.org/8.8/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.

CONFIGURE SUCCESSFUL in 2s
[info] Found 18 tasks

Does the bug still exist if you disable all other extensions?
If I don't install Language Server for Java, I get a Java 17 JDK by default, which is still unexpected. If I install Language Server for Java, I get the same one as above.

@sei-eschwartz sei-eschwartz added the bug Something isn't working label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant