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

Does lsp-java support java 11? #114

Closed
fgabolde opened this issue Mar 26, 2019 · 11 comments
Closed

Does lsp-java support java 11? #114

fgabolde opened this issue Mar 26, 2019 · 11 comments

Comments

@fgabolde
Copy link

I'm having a good time with lsp-mode and lsp-java on most projects at work, which are targeting Java 8. However, for the couple of projects that are targeting Java 11, I immediately run into trouble, with the following message:

Java: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files [16777540]

and a lot of compile errors highlighted in the UI, especially on built-in types like Integer and String, like you'd get if running the wrong JDK. There is probably a misconfiguration on my part, but I can't find it.

The LSP session start looks like this:

!SESSION 2019-03-26 15:24:22.943 -----------------------------------------------
eclipse.buildId=unknown
java.version=11.0.1
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Framework arguments:  --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED
Command-line arguments:  -data /home/fgabolde/.emacs.d/workspace/ --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED

When running M-! java-version, I get:

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-3ubuntu118.04ppa1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-3ubuntu118.04ppa1, mixed mode, sharing)

JAVA_HOME is correctly set as well.

I updated the edt backend very recently, using lsp-java's built-in installer.

What am I doing wrong?

@yyoncho
Copy link
Member

yyoncho commented Mar 26, 2019

It is meant to support even java12 - eclipse-jdtls/eclipse.jdt.ls#970 but for some reason, OpenJDK 11 does not work. I am running oracle jdk 8, do you have an option to switch?

@fgabolde
Copy link
Author

@yyoncho I don't, unfortunately. This is for work, so it would be hard to justify staying on Java 8 until the one guy running a weird Emacs setup can get everything in order :(

Do you know how I could check if the install process picked up the right version of the language server?

@yyoncho
Copy link
Member

yyoncho commented Mar 26, 2019

@yyoncho I don't, unfortunately. This is for work, so it would be hard to justify staying on Java 8 until the one guy running a weird Emacs setup can get everything in order :(

I just want to know in order to determine the priority of the issue. Is Oracle JDK 11 an option?

Do you know how I could check if the install process picked up the right version of the language server?

Why do you think that it might be picking wrong server?

@fgabolde
Copy link
Author

@yyoncho I don't, unfortunately. This is for work, so it would be hard to justify staying on Java 8 until the one guy running a weird Emacs setup can get everything in order :(

I just want to know in order to determine the priority of the issue. Is Oracle JDK 11 an option?

Yes, sure, I can run it locally; the artifacts for production will be built on the CI server anyway. Are you saying the language server works with Oracle JDK 11 but not OpenJDK 11 ?

Why do you think that it might be picking wrong server?

Currently I don't think so, but this was one of the things I wanted to check initially and I wasn't sure how.

@yyoncho
Copy link
Member

yyoncho commented Mar 26, 2019

Yes, sure, I can run it locally; the artifacts for production will be built on the CI server anyway. Are you saying the language server works with Oracle JDK 11 but not OpenJDK 11 ?

It think that it might work. If it doesn't work I will try to find the issue with OpenJDK, it is either in startup params or in JDT LS.

@fgabolde
Copy link
Author

I tried just replacing OpenJDK 11 with Oracle's JDK and it didn't work any better, so I restored OpenJDK 11.

What did work was removing the workspace directory entirely and restarting the LSP server. When I installed lsp-java I had only Java 8 set up, so I had a hunch that like in Eclipse, you need to add the JDKs that you want to use, but since I had no idea what file to edit I removed the whole thing.

Now the Java 11 project works and these files in particular have changed:

  • workspace/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml lists only the JDK 11, while my (regular) Eclipse install lists the JDK 8 as well
  • workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs is harder to read but mentions the JDK 11

@yyoncho
Copy link
Member

yyoncho commented Mar 27, 2019

So we are ok?

@fgabolde
Copy link
Author

Yes, everything works. I do wish this was documented here or on the eclipse.jdt.ls repo though.

Sorry about the noise!

@yyoncho
Copy link
Member

yyoncho commented Mar 27, 2019

@fgabolde can you do that? I am not quite sure that I understood what was the issue (you tried to reuse eclipse workspace initially?)

@fgabolde
Copy link
Author

No, I kept the Eclipse and eclipse.jdt.ls workspaces separate from the start.

What happened I think is that when I had lsp-java install eclipse.jdt.ls, I had only Java 8 set up on my machine, so the LSP got set up for Java 8 only. Later I installed Java 11, but the LSP settings didn't change to match, even when I reinstalled the server.

Eclipse was much the same, but in Eclipse you can open a dialog with a list of configured JDKs and add one. Doing the same with eclipse.jdt.ls is harder since you have to find out which files to edit. Once the LSP's workspace was cleared and LSP reinstalled, the LSP settings included the location of my Java 11 install.

I still don't know how to add a new Java installation without clearing the whole LSP workspace, but at least it works for me now.

@chrismgrayftsinc
Copy link

FYI, something similar happened to me. I have a project that's set up to use Java 11 and I didn't set up my java location before downloading JDT LS so it automatically found Java 8. I also had to nuke the workspace folder to get things to work.

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

No branches or pull requests

3 participants