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

Usability Improvement: Support /usr/libexec/java_home to find path for JDK on macOS #74

Closed
johanneshoehn opened this issue Oct 20, 2016 · 3 comments
Labels

Comments

@johanneshoehn
Copy link

On macOS there is a standard way to find the location of the JDK, invoking /usr/libexec/java_home:
http://stackoverflow.com/questions/18144660/what-is-path-of-jdk-on-mac
https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/java_home.1.html

I was a bit confused that vscode-java didn't work out of the box (also no apparent error message, just a message about installing something in the corner that didn't change. I had to set java.home in the settings to the value returned by /usr/libexec/java_home and then it worked. I guess this should be true on most macOS systems and vscode-java could use it directly to find the java home path, making installation easier.

@gorkem
Copy link
Contributor

gorkem commented Oct 20, 2016

We are actually using a utility to resolve JAVA_HOME which in turn seems to be using the mac utility that you have mentioned.

Does your JAVA_HOME (the value returned from mac utility) point to a JRE or JDK?

@johanneshoehn
Copy link
Author

johanneshoehn commented Oct 20, 2016

JAVA_HOME is not set. I tried doing the same thing as the library does and it should work:

 > env | grep JAVA
 > which javac
/usr/bin/javac
 > readlink /usr/bin/javac
/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
 > ls /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/ | grep home
java_home
 > /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home
 > /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home

When I remove "java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home" from my settings.json again, the status bar keeps says again "Starting Java Language Server...".

Edit: Maybe as an additional help for finding out where exactly things break. The ~/.vscode/extensions/redhat.java-0.0.5/server/ folder was still empty before I set java.home for the first time.

@johanneshoehn
Copy link
Author

I guess the bug is here:

process.env['JAVA_HOME'] = javaHome;

This always sets the JAVA_HOME environmental variable, even if there isn't a correct one found. find-java-home then takes this variable and returns it as a valid java home directory.

@gorkem gorkem added bug and removed need info labels Oct 28, 2016
@gorkem gorkem added this to the Late October 2016 milestone Oct 28, 2016
@gorkem gorkem changed the title Usability Improvement: Support /usr/libexec/java_home to find path for JDK on macOS Usability Improvement: Support /usr/libexec/java_home to find path for JDK on macOS Oct 28, 2016
@gorkem gorkem closed this as completed in 9de9490 Oct 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants