reddit / emacs

Where do i set lsp-java-workspace?

Exzelt8042 · 2022-04-11 10:27
Im trying to set up lsp mode with java however i get a message that the lsp server has stopped everytime i try starting it. From searching the error online, i get that it has something to do with `lsp-java-workspace` but how do you set in the `.emacs`. file? I'm thinking its something like `(setq-default lsp-java-workspace)` but not exactly sure. Also does it work with any version of java or do i need a specific version?
yyoncho · 2022-04-11 10:47
The workspace is in `~/.emacs.d/workspace/` by default. Usually, the issue is that jdtls mess up some of the files and you have to delete the folder to make it work again.
Exzelt8042 · 2022-04-11 10:48
ah, if i have another folder consisting of java programs, how do i make my default workspace that folder?
yyoncho · 2022-04-11 10:51
workspace from the jdtls perspective is just a folder that contains the jdtls cache stuff and related. It is not meant to contain source code.
Exzelt8042 · 2022-04-11 10:58
okay yeah i tried deleting the folder and restarting emacs, but the server still stops as soon as it turns on with an error code of 13
yyoncho · 2022-04-11 14:12
what is your java version? `M-! java -version RET`
Exzelt8042 · 2022-04-11 14:51
openjdk version "1.8.0_332" OpenJDK Runtime Environment (build 1.8.0_332-b04) OpenJDK 64-Bit Server VM (build 25.332-b04, mixed mode)
yyoncho · 2022-04-11 14:52
you must use java 11+
Exzelt8042 · 2022-04-11 16:49
is there a specific Java version you recommend?or just the latest
yyoncho · 2022-04-11 17:58
it should be at least java 11.
Exzelt8042 · 2022-04-11 17:59
okay yeah but then which version should I go for ? 11 or the current version (i think 17)
yyoncho · 2022-04-11 18:08
Whatever you want, there is no other requirement from language server perspective
Exzelt8042 · 2022-04-11 18:09
ah, I'll install it later , thanks
Exzelt8042 · 2022-04-12 02:50
yeah it works , thanks !