Skip to content

Bug: Gradle build error: Supplied javaHome is not a valid folder. You supplied: /usr/local/sdkman/candidates/java/current #1405

Open

Description

Environment:

  • VS Code Version: 1.97.2
  • Extension Version: 3.16.4
  • JDK Type & Version: temurin, 21
  • OS Type & Version: Linux

Step to Reproduce:

Use devcontainer (GitHub Codespaces)

{
    "image": "mcr.microsoft.com/devcontainers/java:21"
}

with a Gradle project

For example use this project: https://github.com/hfhbd/mavencentral and open it with GitHub Codespaces

Expected Behavior:
No issue when opening the Gradle project

Actual Behavior:

[info] [gradle-server] Gradle Server started, listening on 38591
[info] Gradle client connected to server
[info] [gradle-server] Downloading https://services.gradle.org/distributions/gradle-8.13-milestone-3-bin.zip
[info] [gradle-server] ...
[info] [gradle-server] ....
[info] [gradle-server] ..
[info] [gradle-server] ...
[info] Java Home: /usr/local/sdkman/candidates/java/current
[info] JVM Args: -Xmx2048m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant
[info] Gradle User Home: /home/vscode/.gradle
[info] Gradle Version: 8.13-milestone-3
[error] Error getting build for /workspaces/mavencentral: Supplied javaHome is not a valid folder. You supplied: /usr/local/sdkman/candidates/java/current
Image

Related Issues:

Activity

  1. github-actions commented on Sep 15, 2025

    @github-actions

    Hi Philip Wedemann (@hfhbd), I'm an AI Support assistant here to help with your issue. While the team reviews your request, I wanted to provide some possible tips and documentation that might help you in the meantime.

    • Override the Gradle JVM Home in your workspace settings so the extension picks a folder Gradle can validate. In .devcontainer/devcontainer.json (or .vscode/settings.json) add:

    "settings": {
      "java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current"
    }

    Adjust the path to the actual JDK folder if /current is a broken symlink (e.g. /usr/local/sdkman/candidates/java/21.0.x-temurin).

    • As an alternative, set the Gradle property in gradle.properties:

    org.gradle.java.home=/usr/local/sdkman/candidates/java/current

    • See a similar report where overriding java.import.gradle.java.home fixed the “invalid javaHome” error:
    • “The supplied javaHome seems to be invalid. I cannot find the java executable…” (#1325)
    microsoft/vscode-gradle#1325

    labels:

    • bug

    duplicateUrls: []

    The team will respond to your issue shortly. I hope these suggestions are helpful in the meantime. If this comment helped you, please give it a 👍. If the suggestion was not helpful or incorrect, please give it a 👎. Your feedback helps us improve!

  2. Uplink036 commented on Mar 24, 2026

    @Uplink036

    Maybe this will help future travels of this road, do note my problem was with java feature instead of just java base image.

    In my search I found a similar response to the AI, albeit slightly different. the human response was this:

    "containerEnv": {
    	"JAVA_HOME": "/usr/lib/jvm/msopenjdk-current"
    }
    

    That specific path one could get by running which java which returned

    $which java
    /usr/lib/jvm/msopenjdk-current/bin/java

    While this did get the variable to be the correct value, gradle did not respect or use it.

    A solution that worked for me was to specify version,

    	"image": "mcr.microsoft.com/devcontainers/java:3-25-trixie",
    		"ghcr.io/devcontainers/features/java:1": {
    			"version": "25", // Set this to "none" to get the same gradle error
    			"installMaven": "false",
    			"installGradle": "true"
    		}
    

    This got me the sdkman version which gradle wanted.

    Simillar issue on the devcontainer java feature side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions