mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.08k stars 62 forks source link

JavaFX jars not added despite following Troubleshooting instructions #618

Closed UndeadDevel closed 8 months ago

UndeadDevel commented 8 months ago

LSP client configuration

local config = {
    cmd = {'/home/user/bin/jdtls'},
    settings = {
     java = {
       configuration = {
               runtimes = {
           {
             name = "JavaSE-17",
             path = "/usr/lib/jvm/java-17-openjdk-17.0.9.0.9-3.fc38.x86_64/"
           }
         }
       },
       project = {
         referencedLibraries = {
           '/usr/local/lib/javafx/lib/javafx.base.jar',
           '/usr/local/lib/javafx/lib/javafx.graphics.jar',
           '/usr/local/lib/javafx/lib/javafx.controls.jar'
         }
       }
     }
     }
}
require('jdtls').start_or_attach(config)

Eclipse.jdt.ls version

1.9

Steps to Reproduce

I'm trying to set this up for simple and quick experimentation, so no gradle or maven (otherwise I'd just use an IDE) and it works well for just the base JDK, but I'm having trouble with adding in JavaFX. According to the "Troubleshooting" section I can add jar file dependencies as in my above config, but jdtls isn't finding the classes despite that config (I've restarted it as well). The jar files are the standard jars from the openjfx sdk (using SDK 17 to match the JDK). Edit: log only shows "The language server jdtls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless".

Expected Result

Dependencies are added and "searchable" with jdtls. Edit: this issue indicates that it should work this way with JavaFX.

Actual Result

Still only finds the regular JDK classes, not the JavaFX classes.

mfussenegger commented 8 months ago

As far as I'm aware javafx is a bit special because it needs dedicated --module-path/--add-module flags.

See also https://github.com/mfussenegger/nvim-jdtls/discussions/169

I'd really encourage using gradle or maven. It makes your life much easier, and you don't need to use an IDE to use them. The DSL of both isn't that hard and both are easy to use from the command line.

In any case. If the referencedLibraries aren't picked up, that would be a server issue and not a client issue.