You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Question] How to configure the Java binary path used by neotest-java #269
How to set the java path? I already set my JAVA_HOME but it doesn't work (it still use default system path).
neotest-java: ...user/.local/share/nvim/lazy/nvim-nio/lua/nio/control.lua:145: The coroutine failed with this message:
...azy/neotest-java/lua/neotest-java/method_id_resolver.lua:28: Failed to execute javap to resolve method id. Exit code: 127. Stderr: bash: line 1: /usr/lib/jvm
/java-21-openjdk/bin/javap: No such file or directory
neotest-java does not use JAVA_HOME directly. Instead, it resolves the java/javap binaries by querying JDTLS (the Java language server) at runtime via the java.project.getSettings LSP command, specifically reading the org.eclipse.jdt.ls.core.vm.location setting.
So the binary path it uses is whatever JDK JDTLS has configured for your project, not your shell's JAVA_HOME.
The path in your error (/usr/lib/jvm/java-21-openjdk/bin/javap) looks like it was reported correctly by JDTLS — the issue is that the binary doesn't exist at that path on your system. A few things to check:
Is the JDK actually installed at that path? Run ls /usr/lib/jvm/java-21-openjdk/bin/javap to verify. On some distros the package only installs the JRE (no javap) — you may need the full JDK package (e.g. openjdk-21-jdk on Debian/Ubuntu).
Is JDTLS pointing to the right JDK? You can override the JVM JDTLS uses for your project by setting java.jdt.ls.java.home in your LSP config (e.g. via nvim-jdtls's settings table). Make sure it points to a full JDK, not just a JRE.
Verify what JDTLS reports by running this in Neovim while in your Java project:
Activity
rcasia commentedon Mar 31, 2026
Hi @ardikars,
neotest-java does not use
JAVA_HOMEdirectly. Instead, it resolves thejava/javapbinaries by querying JDTLS (the Java language server) at runtime via thejava.project.getSettingsLSP command, specifically reading theorg.eclipse.jdt.ls.core.vm.locationsetting.So the binary path it uses is whatever JDK JDTLS has configured for your project, not your shell's
JAVA_HOME.The path in your error (
/usr/lib/jvm/java-21-openjdk/bin/javap) looks like it was reported correctly by JDTLS — the issue is that the binary doesn't exist at that path on your system. A few things to check:Is the JDK actually installed at that path? Run
ls /usr/lib/jvm/java-21-openjdk/bin/javapto verify. On some distros the package only installs the JRE (nojavap) — you may need the full JDK package (e.g.openjdk-21-jdkon Debian/Ubuntu).Is JDTLS pointing to the right JDK? You can override the JVM JDTLS uses for your project by setting
java.jdt.ls.java.homein your LSP config (e.g. vianvim-jdtls'ssettingstable). Make sure it points to a full JDK, not just a JRE.Verify what JDTLS reports by running this in Neovim while in your Java project:
If you share your JDTLS configuration I can help narrow it down further.
[-][QuestionJ Java Path[/-][+][Question] Java Path[/+][-][Question] Java Path[/-][+][Question] How to configure the Java binary path used by neotest-java[/+]