-
Notifications
You must be signed in to change notification settings - Fork 90
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
Are different JDK/JREs per project possible? #254
Comments
It seems like you can using this https://github.com/redhat-developer/vscode-java/#setting-the-jdk which translates to (setq lsp-java-configuration-runtimes '[(:name "JavaSE-8"
:path "/home/kyoncho/.java-jdk/"
:default t)]) I will close the issue, but you can use it for further questions. |
@yyoncho I was not aware of this option, thank you for pointing it out 👍 Unfortunately I still did not get it to work as I get an error message which I do not understand how to handle. I have added the following to my
But when I start the Java language server I see the following error message in the
I am not sure what this means and what to change 🤔
Maybe you can clarify this for me 🙏 |
I don't know - I have to read the jdtls code to get that for you which I generally can do but I don't have the time. I would recommend you to ask in the server repo. |
No problem, I don't expect you to read it for me 😄 I just thought you might know what is going on. I will check out the jdtls repo and see what I can find out. If I find a solution, I will post it here. |
I haven't figured it out completely, but I will document my progress here for others which might face the same problem: From this issue in the jdtls repository I found out that
This resolves my errors Unfortunately for the project synchronization it still uses the wrong Java version and the original error remains 😿 |
maybe try to delete .project file? |
... and classpath and reimport the project. |
I tried both, but without success 😞 I also found this issue regarding VS Code, but even with those changes I could not make work. The jdtls always uses Java 11 for the |
It seems to work, I have the LSP server running with |
From my testing so far it seems to be more of a Gradle/buildship problem 🤔 The compilation and everything related actually works fine by using From this issue I can currently only assume that Gradle buildship is always started with the Java version which is used for starting the jdtls (in my case "Java 11"), which is incompatible with the Gradle wrapper of my project (which needs "Java 8") and then leads to these I haven't found any workaround for this issue yet. Did you have similar issues with your build tools @deb75? |
FWIW you may use older version. For the other issue, you may ask in server repo... |
Yes of course this is a workaround 😄 I will still check the server repo for an actual solution but otherwise this is done for me. Thank you for all the help 👍 |
I think that there is nothing to do here on lsp-java side. Please reopen if you disagree. |
Looks like VS code tackled this with https://devblogs.microsoft.com/java/java-on-visual-studio-code-update-november-2020/#java-runtime-configuration-wizard Can we do that same using Thanks @CsBigDataHub |
@CsBigDataHub this looks like something that we want to have too. |
Thanks @yyoncho should I create an issue to track the feature? |
With Java using a 6-month release cadence, it's impossible to use emacs to code in Java without being able to tell emacs the JDK to use per-project. I have some projects where I don't use Maven nor Gradle, and would be nice to have somewhere to tell emacs "please use this JDK on this git project", which could perhaps be done by integrating with In IntelliJ, this is trivial to do, it even auto-discovers JDKs installed on the system and has a button to auto-download a particular version. It also lets us choose the API version we want to code against, which means we can use IDE checks for, say, Java 8 (useful for libraries as we may want to keep compatibility for a long time), while still actually compiling locally with Java 17. In emacs, it would be easy to do that by integrating with SDKMAN! in case it's installed. |
Describe the bug
I am currently having problems while working with projects which need a different Java versions for building.
I have installed OpenJDK 11 (my system default) and OpenJDK 8, my
lsp-java
version is 20200725.1809.I have installed the Java language server and initialized the workspace with Java 11, which for the most of my projects works absolutely fine. Unfortunately I also have to work with projects that require Java 8 for building. When I add one of those to my workspace I see the following error message when I start the Java language server:
This makes sense to me as the language server uses Java 11 while the project specific Gradle-Wrapper version only works with Java 8. I am then stuck with a project which can not resolve its dependencies. I can not build it via
lsp-java-build-project
, jump to definitions vialsp-find-definition
or update the project configuration vialsp-java-update-project-configuration
.However when using the Eclipse IDE (on which the language server is based on, if I'm correct) this works fine, because the Java 8 JRE system library was added to the build path. This can also be seen in the corresponding
.classpath
file of the project:Now I have searched quite a bit on how to achieve the same configuration for
lsp-java
but could not find any explanation or solution 😿Is it currently possible to use a different Java JDK/JRE per project like in the Eclipse IDE and get rid of my errors?
lsp-java
or is this an issue with the language server itself?The text was updated successfully, but these errors were encountered: