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

Infer Metals Java Home When Path Symlinks to Java Binary #1094

Open
godenji opened this issue Aug 8, 2022 · 1 comment · May be fixed by scalameta/metals-languageclient#479
Open

Infer Metals Java Home When Path Symlinks to Java Binary #1094

godenji opened this issue Aug 8, 2022 · 1 comment · May be fixed by scalameta/metals-languageclient#479

Comments

@godenji
Copy link

godenji commented Aug 8, 2022

Linux users may have OpenJDK provided by their package manager, which creates a symlink from /usr/bin/java to the actual java home binary.

Since Metals expects java home and not the java binary it's impossible to set the path to /usr/bin/java.

It would be highly convenient if Metals could, when presented with a file instead of a path, walk up the directory structure to actual java home directory.

The status quo is simply hard coding the current java home path, which changes often on package manager updates, so is far from ideal.

@tanishiking
Copy link
Member

@godenji What happens if you reset metals: Java Home settings?

Screen Shot 2022-08-31 at 17 14 10

I guess metals-vscode (locate-java-home) will find the JAVA_HOME.
If no, do you mind running locate-java-home CLI in your environment?

$ npm install -g locate-java-home
$ locate-java-home

(In my case: I get the following JAVA_HOMEs by locate-java-home and metals-vscode will pick the latest one from the list)

❯ locate-java-home
JAVA_HOME directories found:
1.8.0_312 /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home [64-bit] [JDK]
17.0.3 /Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home [64-bit] [JDK]
11.0.11 /Users/tanishiking/Library/Java/JavaVirtualMachines/adopt-openj9-11.0.11/Contents/Home [64-bit] [JDK]
11.0.9 /Users/tanishiking/Library/Java/JavaVirtualMachines/[email protected]/Contents/Home [64-bit] [JDK]
11.0.12 /Users/tanishiking/Library/Java/JavaVirtualMachines/labsjdk-ce-11.0.12-jvmci-20.3-b20/Contents/Home [64-bit] [JDK]
1.8.0_302 /Users/tanishiking/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home [64-bit] [JDK]

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 a pull request may close this issue.

2 participants