Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Connect to a running JDT LS instance

Pavel Mitrafanau edited this page May 9, 2021 · 1 revision

Connect to a running JDT LS instance from VS Code

  1. Install the required software:
  2. Fork and clone this repository
  3. cd vscode-java
  4. Install the dependencies:
    $ npm install
  5. Make sure the path to the JDK is set correctly. It is searched in the following order:
    • the JDK_HOME environment variable
    • the JAVA_HOME environment variable
  6. In the VS Code open the vscode-java project
  7. Open settings.json (User) and append the following fields:
{
    // ...
    "java.import.bazel.enabled": true,
    "java.import.bazel.src.path": "/java/src",
}

Where java.import.bazel.src.path specifies a path to java sources relatively to the packages in your Bazel project. So it means that all of your packages must conform to this layout.

  1. In the debug viewlet, run the Launch Extension - JDTLS Client
  2. Once the test instance in started, open your Bazel project
  3. Open any .java file and wait until the import process is finished (once spinner is stopped). Then you can check whether code navigation (or completion) works.

Problems you can face

In case you've run into a problem not listed here and can't find a solution, clean the workspace directory and try again.

  1. Your Bazel project is being loaded too much time. First, close it. Restart the JDT LS and then try to follow the steps above once again (starting from step 9).