java --version
command, which should result in output similar to the following:
java 18.0.1.1 2022-04-22 Java(TM) SE Runtime Environment (build 18.0.1.1+2-6) Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)
PATH
environment variable.
jdt-language-server-1.9.0-202203031534.tar.gz
package was downloaded from that milestone builds page and the contents extracted to the folder C:\Java\
location as shown below:
Directory of C:\Java\jdt-language-server 04/09/2018 07:26 PM <DIR> . 04/09/2018 07:26 PM <DIR> .. 04/09/2018 06:50 PM <DIR> bin 04/09/2018 06:50 PM <DIR> config_linux 04/09/2018 06:50 PM <DIR> config_mac 04/09/2018 06:50 PM <DIR> config_ss_linux 04/09/2018 06:50 PM <DIR> config_ss_mac 04/09/2018 07:26 PM <DIR> config_ss_win 04/09/2018 07:26 PM <DIR> config_win 04/09/2018 06:50 PM <DIR> features 04/09/2018 06:50 PM <DIR> plugins
C:\Java\jLSP.cmd
batch file:
@echo off set CacheDirctory=%~1 if NOT "%CacheDirctory%" == "" goto test_cache set CacheDirctory=%~2 if NOT "%CacheDirctory%" == "" goto test_cache echo Error: No cache directory was provided. goto usage :test_cache set CacheDirctory="%CacheDirctory%" if EXIST %CacheDirctory% goto check_server echo Error: The cache directory provided does not exist: %CacheDirctory% goto complete :check_server :: language server installation folder (adjust to suit) set Directory=C:/Java/jdt-language-server :: language server jar file (update based on version file of jar) set JarFile=%Directory%/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar if EXIST %JarFile% goto run_server echo Error: The following Jar file was not found: echo '%JarFile%' echo Check the folder above to see if the version number of the Jar has changed and update the jLSP.cmd file to suit. goto complete :run_server :: language server config folder location set Config=%Directory%/config_win echo Directory: %Directory% echo JarFile: %JarFile% echo Config: %Config% :: java --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 %JarFile% :: -configuration %Congfig% :: --add-modules=ALL-SYSTEM :: --add-opens java.base/java.util=ALL-UNNAMED :: --add-opens java.base/java.lang=ALL-UNNAMED :: -data %CacheDirctory% :: echo the command for debugging echo java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory% :: run the language server using stdio communications java -Dosgi.bundles.defaultStartLevel=4 -Declipse.product=org.eclipse.jdt.ls.core.product -Dlog.level=ALL -noverify -Xmx1G -jar %JarFile% -configuration %Config% --add-modules=ALL-SYSTEM --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED -data %CacheDirctory% goto complete :usage echo. echo Usage: jLSP.cmd WorkspaceDirectory FileDirectory echo Example: jLSP.cmd "$wdd" "$fdd" echo. :complete
NOTE: The details found in this batch file may need to be adjusted to suit the local machine. For example the location of the language server, the version number of the language server or the folder location used for data cache may all need to be adjusted.
For more details refer to the 'adjust to suit' and 'update based on version file of jar' comments found in the batch file.
Program Type: Batch Program: C:\Java\jLSP.cmd Directory: Arguments: "$wdd" "$fdd"
"$wdd"
and "$fdd"
are two arguments passed ot the batch file and represent the current workspace directory and the directory of the current file. The batch file
uses these two details to define the location of the language server cache folder.
test.java
file and fire off an auto-complete request: