Skip to content

Unable to set the JAVA_HOME variable used by the Maven extension #1061

Open
@mhrtr-gh

Description

@mhrtr-gh

Describe the bug

When launching the maven extension / terminal within VS Code, I get the error:

Error: JAVA_HOME not found in your environment.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

I do not have JAVA_HOME set as a Windows environment variable.

Setting any of "java.home", "java.jdt.ls.java.home", "maven.terminal.useJavaHome", "maven.terminal.customEnv" appears to have no effect, and the error still occurs.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to 'Command Palette'
  2. Click on '> Java: Create Project'
  3. Click on 'Maven create from archetype'
  4. Click on 'maven-archetype-quickstart'
  5. Click on '1.5'
  6. Enter your 'group_id', 'artifact_id', 'destination folder' when prompted.
  7. Check the Maven terminal window for messages

Expected behavior
The Maven terminal picks up the configured JAVA_HOME setting and successfully executes the command.

Environments (please complete the following information as much as possible):

  • OS: Windows 10
  • VS Code version: 1.96.4
  • Extension version 0.44.0

Additional context
I have tried every combination of the following settings in both my User settings.json file and my workspace settings file:

"java.home": "C:\\LocalApplications\\Java\\openjdk\\jdk-18.0.2.1",

"java.jdt.ls.java.home": "C:\\LocalApplications\\Java\\openjdk\\jdk-18.0.2.1",

"maven.terminal.useJavaHome": true, // also tried false, and removing the line entirely

"maven.terminal.customEnv": [
    {
        "environmentVariable": "JAVA_HOME",                // variable name
        "value": "C:\\LocalApplications\\Java\\openjdk\\jdk-18.0.2.1"      // value
    }
],

I exited and relaunched VS Code between each setting change

I have looked at the following related issues, for information, but none of them offer a solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions