Metals: Support Java 11

Created on 18 Apr 2019  ·  12Comments  ·  Source: scalameta/metals

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?

feature

Most helpful comment

@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 :)

All 12 comments

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:

  • run Java 11 tests on CI, maybe as a daily cron job
  • add a configuration option in VS Code to choose a preferred java version
  • automatically detect the situation when the Metals server and installed Bloop server are running on incompatible Java versions and report a helpful message to the user with instructions on how to fix the problem.

The VS Code Metals experience is a bit confusing with regards to Java 11 support.

  1. The VS Code page on the Metals website lists "Java 8 or 11 provided by OpenJDK or Oracle" as one of the requirements.
  2. That same page says "Metals only works with Java 8 so this executable cannot point to another version such as Java 11" under Configure Java version.
  3. When I install Metals in a container with $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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabro picture gabro  ·  3Comments

ckipp01 picture ckipp01  ·  3Comments

Michaelizm picture Michaelizm  ·  4Comments

iokacha picture iokacha  ·  4Comments

tanishiking picture tanishiking  ·  4Comments