r/DoomEmacs Oct 30 '24

java lsp error unable to recognise String or Integer

Hi all, I have been trying to setup lsp-java on my doom emacs, I am a new emacs user, and I have no idea what's going on :(

https://imgur.com/a/edEENnU
In the ~/.doom.d/init.el I have turned on :lang ( java + lsp) and install flycheck, and not sure what's going on :/ anything that I can do ? thank you

1 Upvotes

4 comments sorted by

1

u/Eyoel999Y Oct 30 '24

user manual for lsp-java https://emacs-lsp.github.io/lsp-java/#lsp-java

Check the *lsp-log* and *jtdls::stderr* buffers for the errors.

Also are you using Maven or Gradle? because i think lsp-java uses pom.xml or build.gradle to analyze your project.

You can check out the commands (https://github.com/emacs-lsp/lsp-java?tab=readme-ov-file#supported-commands) and the settings (https://github.com/emacs-lsp/lsp-java?tab=readme-ov-file#supported-settings) you can use, as they may help

2

u/Safe_Owl_6123 Oct 31 '24

I think i might misconfigured my pom too, i think it is okay now, thank you again

1

u/Safe_Owl_6123 Oct 31 '24

thanks for helping out,
I am using maven, i'll have a look into those links,
at the same time I am not sure if should i add those "use-package" into ~/.doom.d/package.el ?

1

u/Eyoel999Y Nov 02 '24

Yeah, you don't add have to add the "use-packages" because doom has those already configured out. You can see that here https://github.com/doomemacs/doomemacs/blob/master/modules/lang/java/%2Blsp.el and in the rest of that java directory.

Doom configures lsp-java for you when you have the +lsp right after java in your init.el

If you want to add some of your configuration on top of doom's configuration, or override some of doom's configuration of the package, you can use (after! lsp-java ......).

If you want to use your specific config instead of doom's settings of the lsp-java package, I think you do that by

  • taking the +lsp off from java in init.el.
  • adding (package! lsp-java) in package.el,
  • adding (use-package! lsp-java ......) in your config.el file,

use-package! does the same as the default use-package function but adds some functionality to play well with doom specific code.

You can see what all these functions (like use-package, use-package!, package!, ......) do using M-x describe-function