Skip to content

[Question] How to configure the Java binary path used by neotest-java #269

Closed

Description

@ardikars

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

Activity

  1. rcasia commented on Mar 31, 2026

    @rcasia
    Owner

    Hi @ardikars,

    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:

    1. 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).

    2. 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.

    3. Verify what JDTLS reports by running this in Neovim while in your Java project:

      :lua vim.lsp.buf_request(0, "workspace/executeCommand", { command = "java.project.getSettings", arguments = { vim.uri_from_fname(vim.fn.getcwd()), { "org.eclipse.jdt.ls.core.vm.location" } } }, print)

    If you share your JDTLS configuration I can help narrow it down further.

  2. changed the title [-][QuestionJ Java Path[/-] [+][Question] Java Path[/+] on Mar 31, 2026
  3. changed the title [-][Question] Java Path[/-] [+][Question] How to configure the Java binary path used by neotest-java[/+] on Mar 31, 2026
  4. Repository owner locked and limited conversation to collaborators on Mar 31, 2026
  5. converted this issue into a discussion #274 on Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions