Closed gbroques closed 1 year ago
I removed the executable check with https://github.com/mfussenegger/nvim-jdtls/pull/481
Does this fix the problem, or does it still require the cmd.exe workaround?
I removed the executable check with #481
Does this fix the problem, or does it still require the cmd.exe workaround?
Thank you for the swift reply and fix Mathias! 🚀
I re-tested with the latest commit, and no longer need the cmd.exe /c
prefix for cmd
.
It can be tricky on Windows depending on whether you're using a "unix-like" environment such as Cygwin or Git for Windows to know the correct path, slashes, and escaping for configuration.
For me on Windows / Cygwin, here's what worked and didn't work:
cmd = {
"C:/Program Files/Java/jdk-17.0.4.1/bin/java", -- this works ✔
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
-- ... include other arguments
}
cmd = {
"/cygdrive/c/Program\\ Files/Java/jdk-17.0.4.1/bin/java", -- this doesn't work ❌
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
-- ... include other arguments
}
We can probably close this out, but an example cmd
somewhere for Windows would probably still help someone in the future.
Maybe a Windows configuration section in the Sample Configurations page of the Wiki?
Is the preference for it to be a ful and working configuration, rather than a configuration snippet?
I don't really want to link to my dot files as I may switch to Mac in the future.
I could link to a specific commit of my dotfiles though.
Maybe a Windows configuration section in the Sample Configurations page of the Wiki?
That's preferable. This plugin targets more experienced users, not beginners, so it in general assumes that people know their way around their environment and how to format paths.
Problem Statement
Hello Mathias and others.
I found it difficult to get this working on my Windows machine (using Cygwin).
I currently develop Java 11, and need that to be in my
PATH
.As you know, JDTLS needs Java 17 to work though.
What I did to try and work around this was provide a direct path to my
java
17 executable:However, that raises the following error:
See the following
assert
statement insetup
: https://github.com/mfussenegger/nvim-jdtls/blob/0.2.0/lua/jdtls/setup.lua#L218-L219vim.fn.executable
is not reliable on Windows. Even when I added the JDK 17bin
directory to myPATH
(after my JDK 11bin
directory),vim.fn.executable
still returned0
.See https://github.com/wbthomason/packer.nvim/issues/49 for another report of this issue.
To workaround this, I found a solution from the lspconfig project to use
cmd.exe /c
instead.vim.fn.executable
returns1
forcmd.exe
.Then getting the path to my JDK 17 right, with forward-slashes, back-slashes, and the space in "Program Files" took awhile to figure out.
Altogether a working Windows
cmd
looks like:A more complete example can be found in my GitHub config.
Anyways, it would be nice to document this somehow to hopefully prevent other Windows users the same few hours it took me to get this working.
P.S. If you happen to develop Java 17, and have its
bin
directory as the 1st JDK directory in yourPATH
, thencmd
withjava
works fine:For others who don't want Java 17 on their
PATH
, and want to provide a directory to their JDK 17 installation instead, may have trouble configuring it on Windows without a sample configuration.Ideas or possible solutions
No response