The documentation and runtime warnings make it quite clear that Metals requires Java 11.
At some point it would be good if Metals could support Java 11. It might be good to at least start collecting notes on what issues are still holding back support for Java 11?
Thanks for reporting! I think Java 11 support is primarily blocked by Bloop. Supporting Java 11 will also require changes in Metals itself but I estimate it won't be too much effort to implement once Bloop supports Java 11.
Bloop v1.3.0 is out now with JDK 11 support https://github.com/scalacenter/bloop/releases/tag/v1.3.0.
This means it's possible to compile on JDK 11 when Bloop is installed on the computer even if the Metals server runs on JDK 8. We should be able to make the Metals server run on JDK 11 with a few minor changes, such as #739.
We just merged #765 that goes a long way towards enabling Java 11 support. Fuzzy symbol search (workspace/symbol, which is also used for auto-import completions) does not include JDK 11 symbols, otherwise most other functionality should work on Java 11.
The PR #792 fixes the last regression for users running Metals on Java 11. Java 11 support will still remain experimental. There are several issues that we should try to solve before advertising official Java 11 support:
The VS Code Metals experience is a bit confusing with regards to Java 11 support.
Configure Java version.$JAVA_HOME pointed at /usr/local/openjdk-11, I get a warning from Metals saying "Unable to find Java 8 home. To fix this problem, update the 'Java Home' setting to point to a Java 8 home directory".So what exactly is the status of this issue? Thanks in advance.
Fixing the docs issue here: https://github.com/scalameta/metals/pull/883
As for Java Home, we only try to find by default java 8, for java 11 you need to specify it in Metals settings. To fix this we would need to look for 11 here: https://github.com/scalameta/metals-vscode/blob/master/src/getJavaHome.ts
@tgodzik Thank you very much for your action on this. I can confirm that setting the metals.javaHome setting to /usr/local/openjdk-11 allows Metals to start up just fine. Consider this my +1 to add Java 11 to the default search paths in that linked file :)
Hi, Do I need to set the javaHome for metals-emacs?
Hi, Do I need to set the javaHome for metals-emacs?
I don't think so, but I am not sure how exactly we set java-home for emacs. The issue itself should only be a problem in vscode plugin
I think the “java” binary on your path is used when running the metals-emacs binary.
@tgodzik Thanks tons for your kindly help! :+1:
Closing this issue due to the improvements in #995, thanks @andyczerwonka. After https://github.com/scalameta/metals-vscode/pull/154 is merged, Java 11 will by default be picked over Java 8 installations in VS Code.
Java 11 has been supported for a while now for, this issue was only kept open as a reminder to improve the documentation and default settings for detecting Java 11 installations.
Most helpful comment
@tgodzik Thank you very much for your action on this. I can confirm that setting the
metals.javaHomesetting to/usr/local/openjdk-11allows Metals to start up just fine. Consider this my +1 to add Java 11 to the default search paths in that linked file :)