-
Notifications
You must be signed in to change notification settings - Fork 30
Description
What happened?
My $JAVA_HOME environment variable points to JDK 8 because I'm working on several projects that require Java 8. Since JDTLS requires Java 17+, I added the following to my Zed configuration:
{
"lsp": {
"jdtls": {
"initialization_options": {
"settings": {
"java": {
"home": "/Users/username/.sdkman/candidates/java/21.0.4-tem"
}
}
}
}
}
}but it doesn't work, it throws the following error, seems that it's still using the $JAVA_HOME version:
Language server error: jdtls
oneshot canceled
-- stderr--
Traceback (most recent call last):
File "/Users/username/Library/Application Support/Zed/extensions/work/java/jdt-language-server-1.40.0/bin/jdtls", line 17, in <module>
jdtls.main(sys.argv[1:])
~~~~~~~~~~^^^^^^^^^^^^^^
File "/Users/username/Library/Application Support/Zed/extensions/work/java/jdt-language-server-1.40.0/bin/jdtls.py", line 87, in main
java_executable = get_java_executable(known_args)
File "/Users/username/Library/Application Support/Zed/extensions/work/java/jdt-language-server-1.40.0/bin/jdtls.py", line 44, in get_java_executable
raise Exception("jdtls requires at least Java 17")
Exception: jdtls requires at least Java 17
If I change my $JAVA_HOME to Java 21, the plugin starts the server correctly.
If I start the server directly with the following command, the server starts fine, it uses the -Djava.home argument I pass instead of the $JAVA_HOME environment variable so I don't think it's a JDTLS issue:
java \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 \
-Djava.home=/Users/username/.sdkman/candidates/java/21.0.4-tem \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.protocol=true -Dlog.level=ALL -Xmx1G \
-jar "/Users/username/Library/Application Support/Zed/extensions/work/java/jdt-language-server-1.40.0/plugins/org.eclipse.equinox.launcher_1.6.900.v20240613-2009.jar" \
-configuration ./config_mac -data /Users/username/code/java-projectI was able to reproduce this in two computers: a M3 MacBook Pro (macOS Sequoia) and an M1 MacBook Pro (macOS Sonoma).
Am I configuring the wrong setting?
What did you expect to happen?
The plugin should start JDTLS using the lsp.jdtls.initialization_options.settings.java.home as specified in the README.