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

Skip setting JAVA_HOME when using system JDK #350

Merged
merged 1 commit into from
Mar 16, 2024
Merged

Skip setting JAVA_HOME when using system JDK #350

merged 1 commit into from
Mar 16, 2024

Conversation

fwcd
Copy link
Contributor

@fwcd fwcd commented Mar 18, 2022

Currently JAVA_HOME is set to the nonexistent path ~/.jenv/versions/system when using the system JDK, which causes a range of strange inconsistencies. For example, the JAVA_HOME will diverge from System.getProperty("java.home"), e.g. like this when using a Homebrew-installed OpenJDK 17 installation:

System.getenv("JAVA_HOME")      => "~/.jenv/versions/system"
System.getProperty("java.home") => "/opt/homebrew/Cellar/openjdk/17.0.2/libexec/openjdk.jdk/Contents/Home"

Additionally, invoking tools like Gradle that rely on JAVA_HOME from the Java application will fail since JAVA_HOME generally takes precedence over other methods of finding a JDK and in this case points to an invalid path.

This PR fixes this by simply not setting JAVA_HOME whenever the system JDK is used.

@bkmeneguello
Copy link

Also, the export plugin must be updated to avoid exporting the JAVA_HOME when system is used.

@andrewflbarnes
Copy link
Contributor

Fixes #422 .

Thanks for the observation @bkmeneguello - we can do this in a separate PR given lack of activity in this one

@andrewflbarnes andrewflbarnes merged commit 56b2563 into jenv:master Mar 16, 2024
@fwcd fwcd deleted the skip-javahome-system-jdk branch March 16, 2024 04:56
@fwcd
Copy link
Contributor Author

fwcd commented Mar 16, 2024

Ah thanks, sorry for the inactivity!

@andrewflbarnes
Copy link
Contributor

No worries - should have tagged you to check!

Thanks for the contribution @fwcd 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants