Skip to content

Even when explicitly configured to use Java 24, the jdtls continues to use the environment's Java version (8) #69

@behrangsa

Description

@behrangsa

Relevance Confirmation

  • I confirmed that this is not an issue with the Eclipse JDT Language Server itself

What happened?

Summary

jdtls picks up the sdkman's current Java version (8), instead of the one specified in the settings (24)

Description

I have configured Zed to use Java 24 for jdtls. Here's my project's .zed/settings.json:

{
    "lsp": {
        "jdtls": {
            "initialization_options": {
                "settings": {
                    "home": "/home/behrangsa/.sdkman/candidates/java/24.0.1-tem",
                    "jdt": {
                        "ls": {
                            "lombokSupport": {
                                "enabled": false
                            }
                        }
                    },
                    "referencesCodeLens": {
                        "enabled": true
                    },
                    "signatureHelp": {
                        "enabled": true
                    },
                    "implementationsCodeLens": {
                        "enabled": true
                    },
                    "format": {
                        "enabled": true
                    },
                    "saveActions": {
                        "organizeImports": true
                    },
                    "autobuild": {
                        "enabled": false
                    }
                }
            }
        }
    }
}

NOTE: jdtls is also configured in ~/.config/zed/settings.json:

...
    "lsp": {
        "jdtls": {
            "initialization_options": {
                "settings": {
                    "home": "/home/behrangsa/.sdkman/candidates/java/24.0.1-tem"
                }
            }
        }
    },
...

But it uses the version that's setup as the current Java by sdkman:

$ java -version
openjdk version "1.8.0_452"
OpenJDK Runtime Environment Corretto-8.452.09.1 (build 1.8.0_452-b09)
OpenJDK 64-Bit Server VM Corretto-8.452.09.1 (build 25.452-b09, mixed mode)

$ sdk current java
Using java version 8.0.452-amzn

Steps to reproduce:

  1. Use sdkman and install both of Java 24 and Java 8, as well as Maven 3.3.9 on your system
    $ sdk list java | grep -i installed
                   | >>> | 8.0.452      | amzn    | installed  | 8.0.452-amzn
                   |     | 24.0.1       | graal   | installed  | 24.0.1-graal
     Temurin       |     | 24.0.1       | tem     | installed  | 24.0.1-tem
                   |     | 21.0.7       | tem     | installed  | 21.0.7-tem
                   |     | 17.0.14      | tem     | installed  | 17.0.14-tem
                   |     | 11.0.27      | tem     | installed  | 11.0.27-tem
                   |     | 7.0.352      | zulu    | installed  | 7.0.352-zulu
  2. Make Java 8 the default Java
  3. Add the following .sdkmanrc to the root of your project:
    # Enable auto-env through the sdkman_auto_env config
    # Add key=value pairs of SDKs to use below
    java=8.0.452-amzn
    maven=3.3.9
    
  4. Configure jdtls to use Java 24

Actual Behavior:

It should have used Java 24, and ran successfully.

Expected Behavior:

It uses Java 8, and fails:

Language server jdtls:

initializing server jdtls, id 3
-- stderr--
Traceback (most recent call last):
  File "/home/behrangsa/.local/share/zed/extensions/work/java/jdtls/jdt-language-server-1.48.0-202506271502/bin/jdtls", line 26, in <module>
    jdtls.main(sys.argv[1:])
    ~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/behrangsa/.local/share/zed/extensions/work/java/jdtls/jdt-language-server-1.48.0-202506271502/bin/jdtls.py", line 91, in main
    java_executable = get_java_executable(known_args)
  File "/home/behrangsa/.local/share/zed/extensions/work/java/jdtls/jdt-language-server-1.48.0-202506271502/bin/jdtls.py", line 44, in get_java_executable
    raise Exception("jdtls requires at least Java 21")
Exception: jdtls requires at least Java 21

Zed Version and System Specs

Zed: v0.194.3 (Zed)
OS: Linux Wayland ubuntu 24.04
Memory: 15 GiB
Architecture: x86_64
GPU: AMD Radeon Graphics (RADV RENOIR) || radv || Mesa 24.2.8-1ubuntu1~24.04.1

What did you expect to happen?

Please see #jdtl.

Environment

Please see #jdtl.

Metadata

Metadata

Assignees

No one assigned

    Labels

    language-serverRelated to the language server.

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions