Skip to content
Java language server using the Java compiler API
Branch: master
Clone or download
Latest commit 6c8b2e5 Apr 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Use script Jan 9, 2019
.vscode Use test wrapper to set JAVA_HOME Jan 19, 2019
git_hooks Change to width 120 May 21, 2018
images Fix images Apr 15, 2018
lib Put back constants Apr 2, 2019
scripts Re-use compilation tasks Mar 31, 2019
src TODOs Apr 3, 2019
.gitignore Build for windows Dec 29, 2018
.vscodeignore Update May 27, 2016 Add installation instructions for vim Feb 18, 2019
configure Auto-format on commit Jul 22, 2017
icon.png Revert "Icon" Jun 15, 2016
package-lock.json 0.2.17 Apr 17, 2019
pom.xml Demo how to re-use compiler Mar 31, 2019
tsconfig.json Cleanup Jul 1, 2018 Generated from yeoman Mar 12, 2016

Language Server for Java using the Java compiler API

A Java language server based on v3.0 of the protocol and implemented using the Java compiler API.


Installation (VS Code)

Install from the VS Code marketplace

Installation (other editors)

Vim (with vim-lsc)

  • Checkout this repository
  • Run ./scripts/
  • Add the vim plugin natebosch/vim-lsc to your vimrc
  • Add vim-lsc configuration:
    let g:lsc_server_commands = {'java': '<path-to-java-language-server>/java-language-server/dist/mac/bin/launcher --quiet'}
  • See the vim-lsc README for other configuration options.

Note: This tool is not compatible with vim-lsp as it only supports LSPv2.0.





Signature help

Signature help

Autocomplete symbols (with auto-import)

Auto import 1

Auto import 2

Autocomplete members

Autocomplete members


Goto 1

Goto 2

Find symbols

Find workspace symbols

Find document symbols


Error highlight

Type information on hover

Type hover

Find references

Find references 1

Find references 2


The language server will provide autocomplete and other features using:

  • .java files anywhere in your workspace
  • Java platform classes
  • External dependencies specified using pom.xml, Bazel, or settings


If the language server doesn't detect your external dependencies automatically, you can specify them using .vscode/settings.json

    "java.externalDependencies": [
        "junit:junit:jar:4.12:test", // Maven format
        "junit:junit:4.12" // Gradle-style format is also allowed

If all else fails, you can specify the java class path manually:

    "java.classPath": [

You can generate a list of external dependencies using your build tool:

  • Maven: mvn dependency:list
  • Gradle: gradle dependencies

The Java language server will look for the dependencies you specify in java.externalDependencies in your Maven and Gradle caches ~/.m2 and ~/.gradle. You should use your build tool to download the library and source jars of all your dependencies so that the Java language server can find them:

  • Maven
    • mvn dependency:resolve for compilation and autocomplete
    • mvn dependency:resolve -Dclassifier=sources for inline Javadoc help
  • Gradle
    • gradle dependencies for compilation and autocomplete
    • Include classifier: sources in your build.gradle for inline Javadoc help, for example:
      dependencies {
          testCompile group: 'junit', name: 'junit', version: '4.+'
          testCompile group: 'junit', name: 'junit', version: '4.+', classifier: 'sources'


The Java language server uses the Java compiler API to implement language features like linting, autocomplete, and smart navigation, and the language server protocol to communicate with text editors like VSCode.

Incremental updates

The Java compiler API provides incremental compilation at the level of files: you can create a long-lived instance of the Java compiler, and as the user edits, you only need to recompile files that have changed. The Java language server optimizes this further by focusing compilation on the region of interest by erasing irrelevant code. For example, suppose we want to provide autocomplete after print in the below code:

class Printer {
    void printFoo() {
    void printBar() {
    void main() {
        print // Autocomplete here

None of the code inside printFoo() and printBar() is relevant to autocompleting print. Before servicing the autocomplete request, the Java language server erases the contents of these methods:

class Printer {
    void printFoo() {
    void printBar() {
    void main() {
        print // Autocomplete here

For most requests, the vast majority of code can be erased, dramatically speeding up compilation.


The java service process will output a log file to stderr, which is visible in VSCode using View / Output, under "Java".


If you have npm and maven installed, you should be able to install locally using

npm install -g vsce
npm install

At the time of this writing, the build only works on Mac, because of the way it uses JLink. However, it would be straightforward to fix this by changing scripts/ to be more like scripts/

You can’t perform that action at this time.