Skip to content

bug: jdtls is not using jdk-21 #204

@kyerpotts

Description

@kyerpotts

Did you check docs and existing issues?

  • I have read all the plugin docs
  • I have searched the existing issues
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.0 release

Operating system/version

Arch Linux

Describe the bug

My default version of Java is 21, and I have set the default java path in lspconfig to the binary. When I attempt to run or debug, I receive an UnsupportedClassVersionError. I believe this is because openjdk-17 is hardcoded into the nvim-java plugin for builds, however it uses the specified runtime binary configured by lspconfig. I have resolved the issue by setting my default java runtime version to 17 and updating the required path, however it would be useful to be able to change the javac version as a config for the nvim-java in order to avoid ClassVersionErrors.

Steps To Reproduce

  1. Install java 21 using sdkman
  2. Set up nvim-java
  3. set up mason, mason-lspconfig and lspconfig.
  4. setup jdtls using lspconfig.
    require("lspconfig").jdtls.setup({ settings = { java = { configuration = { runtimes = { { name = "JavaSE-21", path ="/PATH/TO/JAVA/RUNTIME/21", default = true, }, }, },
  5. Run debugger / JavaRunnerRunMain

Expected Behavior

nvim-java should use the same javac version as the currently specified runtime version configured by jdtls. An option to set the sdk used by nvim-java would also fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions