LSP java server starts and exits immediately
deb75 opened this issue ยท 21 comments
Hello,
When I load a java file in emacs
(on windows 10), the LSP server starts and exits immediately :
using config for config_win
LSP :: Sending to process failed with the following error: Writing to process: Invalid argument, jdtls
LSP :: Connected to [jdtls:14124 status:starting].
LSP :: jdtls has exited (exited abnormally with code 13)
Server jdtls:14124 status:starting exited with status exit. Do you want to restart it? (y or n) n
It looks strange for me as it used to work perfectly before I updated all emacs
packages and the LSP server to their latest versions.
I made no changes in the LSP configuration and there are no errors from config when emacs 26.1
starts itself.
I wiped out the workspace directory and the LSP session file, still same behavior. Also, nothing is written in this latest directory by the LSP server starting.
What could help me is to understand what means "code 13" ?
Thanks in advance for your kind help.
Regards
deb75
The latest server requires java 11, see eclipse-jdtls/eclipse.jdt.ls#1509
Edit:
Solution 1: Upgrade to Java 11.
Solution 2: do
(setq lsp-java-jdt-download-url "https://download.eclipse.org/jdtls/milestones/0.57.0/jdt-language-server-0.57.0-202006172108.tar.gz")
Delete the server and download it again.
But I cannot upgrade easily java
. how can I stay with previous version ?
check lsp-java-jdt-download-url and this https://projects.eclipse.org/projects/eclipse.jdt.ls/downloads
It is bound to https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz
How may I modify it ? I saw on eclipse.jdt.ls
release page that latest version is 59. Will the 58 version wotk with java 8 ?
Many thanks for your help
Regards
Modify it with setq
Will the 58 version wotk with java 8 ?
I guess yes.
Problem solved by downgrading the eclipse.jdt.ls
server to 0.58.X
It is a pity however that I can no more benefit from the server updates because these one do not maintain a backward compatibility. Probably, java 8
is thought as already too old, unfortunately it is not the leading opinion in my company.
Great thanks for your help.
Regards
@deb75 Afaik, the server requires Java 11 only to run. You can compile your code against Java 8 and you can have both versions installed side-by-side. Java 8 is EOL except for companies that pay for support so I assume Eclipse are just upgrading to a supported version to avoid things like security vulnerabilities and to take advantage of new features.
Thanks for the note !
But how can I tell lsp-java
to start the server with java 11
?
In my settings I have :
(use-package lsp-java
:defer 3
:init
(setq-default lsp-java-server-install-dir "C:/Users/xxx/.emacs.d/lsp/server/eclipse.jdt.ls/")
(setq lsp-java-server-install-dir "C:/Users/xxx/.emacs.d/lsp/server/eclipse.jdt.ls/")
(setq lsp-java-format-settings-url "file:///C:/Users/xxx/.emacs.d/lsp/formatter.xml")
(setq lsp-java-format-settings-profile "JavaAlgoConventions")
(setq lsp-java-java-path "D:/xxx/Documents/utils/jdk1.8.0_202/jre/bin/java.exe")
Is lsp-java-java-path
the right variable ?
yes.
Then, which java version lsp-java
will use to compile source files ? How do I tell lsp-java
the version with which to compile ?
Regards
EDIT : according to the wiki (bottom of the page), lsp-java
will use the java version it finds on the executable path. So, in order to use latest server, I just have to make lsp-java-java-path
point to java jre 11 and not putting it into the path, so that the server still peeks up java 8 from the executable path ?
Am I right ?
Regards
As far as I know (at least of Mac OSX), Eclipse auto-discovers all installed Java versions and I think it will use the correct one depending on the source compatibility version (for compilation) and target compatibility version (for running). @yyoncho will probably know whether this is correct.
You can also run a test by trying to use Java 11 features and see what happens.
Sorry, I am just lost, where do you write the settings "java.configuration.runtimes" ?
At my root project, there is a .settings
directory, in which file ?
I created a file .vscode/settings.json
at the root of my project :
"java.home": "D:/xxx/Documents/utils/jdk-11.0.8+10"
"java.configuration.runtimes": [
{
"name": "Oracle JDK 8",
"path": "D:/xxx/Documents/utils/jdk1.8.0_202",
"default": true
},
]
"java.format.settings.url": "file:///C:/Users/xxx/.emacs.d/lsp/formatter.xml"
"java.format.settings.profile": "JavaAlgoConventions"
But it does not seem to work.
this: https://github.com/redhat-developer/vscode-java/#setting-the-jdk
I have seen in lsp-java.el
the custom variable :
(defcustom lsp-java-configuration-runtimes nil
"Map Java Execution Environments to local JDKs."
:type 'lsp-string-vector)
which seems to do exactly what I want to do. How can I configure it so that it points to another jdk ?
Regards
Here it is an example how to use it:
(setq lsp-java-configuration-runtimes '[(:name "JavaSE-8"
:path "/home/kyoncho/.java-jdk/"
:default t)])
Here it is an example how to use it:
(setq lsp-java-configuration-runtimes '[(:name "JavaSE-8" :path "/home/kyoncho/.java-jdk/" :default t)])
This, together with wiping out the workspace and project settings (not sure if it was necessary) worked ๐
I have no more messages that the current compiler version is distinct from the one required by the pom.xml
file.
I have Java 11, OpenJDK 11.0.10 on Ubuntu 20.04. I configure lsp-java
as follows.
(use-package lsp-java
:hook (java-mode .
(lambda ()
(setq-default c-basic-offset 4
c-set-style "java")
(lsp-deferred)))
:init
(setq lsp-java-inhibit-message nil)
(setq lsp-java-java-path "/usr/lib/jvm/java-11-openjdk-amd64/bin/java")
(setq lsp-java-save-actions-organize-imports t))
However, the JDT server is exiting immediately. I am not sure what changed, it was working till about three days back. What could be the issue here?
Try to delete lsp-java-workspace-dir
Thanks, @yyoncho, that worked. Maybe lsp-java
can check for repeated failures of JDTLS
and provide these tips as possible troubleshooting, or even offer to automatically delete the directory?
Just a heads up, If your main JDK is version 11+ and you want your project to compile for example to jdk 8, and you are using maven or gradle you can set the level the compiler will produce the bytecode, for Maven you can configure the compiler plugin and gradle the java
plugin