This project demonstrates how to launch the Eclipse Java Language Server (aka: Eclipse jdt-ls) and access it using a Java Language client able to pass commands and get JSOn responses converted to objects
The project uses a java maven example project where some class contains the annotation @MySearchableAnnotation
that we would like to search about.
First, compile the project and generate the classpath file:
mvn clean compile
Download and unzip the Eclipse JDT Language Server:
wget https://www.eclipse.org/downloads/download.php?file=/jdtls/milestones/1.50.0/jdt-language-server-1.50.0-202509041425.tar.gz > jdt-language-server-1.50.0.tar.gz
mkdir jdt-ls
tar -vxf jdt-language-server-1.50.0.tar.gz -C jdt-ls
Alternatively, you can also download and/or use your own server:
set VERSION latest
set ID $(podman create --name kantra-download quay.io/konveyor/kantra:$VERSION)
podman cp $ID:/jdtls ./konveyor-jdtls
Copy the konveyor-jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/java-analyzer-bundle.core-1.0.0-SNAPSHOT.jarjava-analyzer-bundle.core-1.0.0-SNAPSHOT.jar
to the ./lib/
of this project to allow maven to load it as it is not published on a maven repository server !
Here is the trick to do to add a bundle to the OSGI jdt-ls server. This step is optional as we will pass the bundle path as initialization parameter to the language server !
Edit the config.ini
file corresponding to your architecture: mac, linux, mac_arm under the folder konveyor-jdtls/config_
Modify within the config.ini file the osgi.bundles
property and include after the org.apache.commons.lang3...
jar the BundleSymbolicName of: java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar
osgi.bundles=...org.apache.commons.lang3_3.14.0.jar@4,reference\:file\:java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar@2,...
Copy the java-analyzer-bundle.core-1.0.0-SNAPSHOT.jar file from the path konveyor-jdtls/java-analyzer-bundle/java-analyzer-bundle.core/target/
to the plugins
folder
Before to run the server and client, configure the following properties:
JDT_WKS
: Path if the folder containing the jdt-ls workspace, .metadata and logJDT_LS_PATH
: Path of the jdt-ls folderLS_CMD
: Language server command to be executed. Example:java.project.getAll
, etc
# LS_CMD "java.project.getAll"
# LS_CMD "io.konveyor.tackle.samplecommand"
# LS_CMD "io.konveyor.tackle.ruleEntry"
# JDT_LS_PATH "$HOME/code/application-modernisation/lsp/jdtls"
# JDT_LS_PATH "$HOME/code/application-modernisation/lsp/konveyor-jdtls"
mvn exec:java \
-DJDT_WKS=$HOME/code/application-modernisation/lsp \
-DJDT_LS_PATH=$HOME/code/application-modernisation/lsp/jdtls \
-DLS_CMD=java.project.getAll
You can check the log of the server from the parent folder within: .jdt_workspace/.metadata/.log
!