Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

JAVA_HOME points to sdkman jdk home instead of microsoft Java home #1646

Closed
dashorst opened this issue Sep 27, 2022 · 3 comments
Closed

JAVA_HOME points to sdkman jdk home instead of microsoft Java home #1646

dashorst opened this issue Sep 27, 2022 · 3 comments

Comments

@dashorst
Copy link

dashorst commented Sep 27, 2022

  • VSCode Version: Version: 1.71.2 (Universal) Commit: 74b1f979648cc44d385a2286793c226e611f59e7
  • Local OS Version: macOS Monterrey 12.6
  • Local chip architecture: Apple Silicon
  • Reproduces in: Remote - Containers
  • Name of Dev Container Definition with Issue: Java (no qualifiers)

The devcontainer.json points to this URL:
https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/java

The Dockerfile points to this parent container:

ARG VARIANT="17-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}

Steps to Reproduce:

  1. add remote container files to project
  2. select java
  3. select maven (no node or gradle)
  4. select java 17 (bullseye)
  5. no other extensions
  6. start mvn in the terminal
  7. get error that JAVA_HOME is invalid
$ mvn help:help
The JAVA_HOME environment variable is not defined correctly,
this environment variable is needed to run this program.

JAVA_HOME points to this:

$ echo $JAVA_HOME
/usr/local/sdkman/candidates/java/current

However when I run java --version:

$ java --version
openjdk 17.0.4.1 2022-08-12 LTS
OpenJDK Runtime Environment Microsoft-40354 (build 17.0.4.1+1-LTS)
OpenJDK 64-Bit Server VM Microsoft-40354 (build 17.0.4.1+1-LTS, mixed mode)

And look where it gets its cup of Java from:

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

This says to me that the configuration of the Java image is not correct.

Literally a week ago this worked without any problems.

@Danielv123
Copy link

Danielv123 commented Oct 3, 2022

I had the same issue with java 11, added the following to .devcontainer.json to fix it.

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

@nielspardon
Copy link

It seems JAVA_HOME is still correctly set in the following container image tags: 0.205.4-${VARIANT}. If you change your Dockerfile in the following way it should work properly again:

-FROM mcr.microsoft.com/vscode/devcontainers/java:0-${VARIANT}
+FROM mcr.microsoft.com/vscode/devcontainers/java:0.205.4-${VARIANT}

Just adding the manual JAVA_HOME env variable was not enough for me since VS Code could not communicate with the Gradle server properly.

@joshspicer since you are the one who last touched containers/java/definition-manifest.json can you help to get this fixed or find the right person who can fix this?

@Chuxel
Copy link
Member

Chuxel commented Oct 12, 2022

It looks like this is an issue with the updated image in its new home at https://github.com/devcontainers/images.

Copied this issue to the new location. Closing here as a dupe - though this does look like a bug.

New issue is devcontainers/images#158

@Chuxel Chuxel closed this as completed Oct 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants