One has to specify the correct plugin to initialize the (Eclipse)language server within the JDK.
We can do this by creating a shell script that is called by your nvim LSP plugin/config.
First you have to locate the equinox_launcher jar file, which is located in the eclipse/jdt-language-server/plugin folder and add it to your script.
Linux shell script should look something like this:
#!/usr/bin/env/ bash
JAR="path/to/your/eclipse/build/plugins/org.eclipse.equinox.launcher_longnumberhere.jar"
GRADLE_HOME=$HOME/where_gradle_lives/gradle $JAVA_HOME/or_absolute_path \/bin/java \
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044 \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.level=ALL -noverify \
-Xmx1G -jar echo $(JAR) \ // points to the plugin
-configuration ./config_linux \ // points to the config folder within jdtls
-data /path/to/data \
--add-modules=ALL-SYSTEM \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED
Win batch script should look something like this:
SET "JAR=path\to\your\eclipse\build\plugins\org.eclipse.equinox.launcher_longnumberhere.jar"
SET "GRADLE_HOME=path\where\gradle\lives\gradle %JAVA_HOME%\or_absolute_path\bin\java"^
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=1044^
-Declipse.application=org.eclipse.jdt.ls.core.id1^
-Dosgi.bundles.defaultStartLevel=4^
-Declipse.product=org.eclipse.jdt.ls.core.product^
-Dlog.level=ALL^
-noverify^
-Xmx1G -jar echo %JAR%^ // this points to the plugin
-configuration .\config_win^ // points to the config folder within jdtls
-data \path\to\data^
--add-modules=ALL-SYSTEM^
--add-opens java.base/java.util=ALL-UNNAMED^
--add-opens java.base/java.lang=ALL-UNNAMED
After the agentlib line, you can add the modules you need.
For further conveniences, the java_lsp.sh or java_lsp.bat can be included in a environment path.
The jdtls target directories can vary if you build from source, or (recommended) use a Milestone build.
https://download.eclipse.org/jdtls/milestones/
For more detailed information you can check out:
Neovim built in LSP documentation:
Guide + documentation regarding JDTLS:
Guide + Examples Regarding JDTLS client plugin for nvim written in lua: