{"id":13450881,"url":"https://github.com/georgewfraser/java-language-server","last_synced_at":"2025-05-06T22:17:36.863Z","repository":{"id":39950516,"uuid":"53765018","full_name":"georgewfraser/java-language-server","owner":"georgewfraser","description":"Java language server using the Java compiler API","archived":false,"fork":false,"pushed_at":"2024-06-15T14:14:00.000Z","size":44876,"stargazers_count":701,"open_issues_count":131,"forks_count":139,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-06T22:17:02.216Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/georgewfraser.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-13T03:08:19.000Z","updated_at":"2025-05-06T20:20:04.000Z","dependencies_parsed_at":"2024-10-28T16:53:20.108Z","dependency_job_id":null,"html_url":"https://github.com/georgewfraser/java-language-server","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgewfraser%2Fjava-language-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgewfraser%2Fjava-language-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgewfraser%2Fjava-language-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/georgewfraser%2Fjava-language-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/georgewfraser","download_url":"https://codeload.github.com/georgewfraser/java-language-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776605,"owners_count":21802469,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T07:00:39.728Z","updated_at":"2025-05-06T22:17:36.833Z","avatar_url":"https://github.com/georgewfraser.png","language":"Java","readme":"# Language Server for Java using the [Java compiler API](https://docs.oracle.com/javase/10/docs/api/jdk.compiler-summary.html)\n\nA Java [language server](https://github.com/Microsoft/vscode-languageserver-protocol) based on v3.0 of the protocol and implemented using the Java compiler API.\n\n## Installation (VS Code)\n\n[Install from the VS Code marketplace](https://marketplace.visualstudio.com/items?itemName=georgewfraser.vscode-javac)\n\n## Installation (other editors)\n\n### Vim (with vim-lsc)\n\n- Checkout this repository\n- Run `./scripts/link_{linux|mac|windows}.sh`\n- Run `mvn package -DskipTests`\n- Add the vim plugin [natebosch/vim-lsc](https://github.com/natebosch/vim-lsc) to your vimrc\n- Add vim-lsc configuration:\n  ```vimrc\n  let g:lsc_server_commands = {'java': '\u003cpath-to-java-language-server\u003e/java-language-server/dist/lang_server_{linux|mac|windows}.sh'}\n  ```\n- See the [vim-lsc README](https://github.com/natebosch/vim-lsc/blob/master/README.md) for other configuration options.\n\nNote: This tool is not compatible with [vim-lsp](https://github.com/prabirshrestha/vim-lsp) as it only supports LSPv2.0.\n\n### KDE Kate\n\n- Checkout this repository\n- Run `./scripts/link_{linux|mac|windows}.sh`\n- Run `mvn package -DskipTests`\n- Open your Kate editor\n- Go to Settings \u003e Configure Kate... \u003e LSP Client \u003e User Server Settings\n- Add this lines to your User Server Settings:\n```json\n{\n    \"servers\":\n    {\n        \"java\":\n        {\n            \"command\": [\"bash\",\"\u003cpath-to-java-language-server\u003e/java-language-server/dist/lang_server_{linux|mac|windows}.sh\"],\n            \"url\": \"https://github.com/georgewfraser/java-language-server\",\n            \"highlightingModeRegex\": \"^Java$\"\n        }\n    }\n}\n```\n\n\n### Sublime 3 (with LSP)\n\n- Checkout this repository\n- Run `./scripts/link_{linux|mac|windows}.sh`\n- Run `mvn package -DskipTests`\n- Open your Sublime 3\n- Install Package Control (if missing)\n- Install the [LSP Package](https://packagecontrol.io/packages/LSP) (if missing)\n- In Sublime, go to Preferences \u003e Package Settings \u003e LSP \u003e Settings\n- Add this lines to your LSP Settings:\n```json\n{\n    \"clients\":\n    {\n        \"jls\":\n        {\n            \"enabled\": true,\n            \"command\": [\"bash\", \"\u003cpath-to-java-language-server\u003e/java-language-server/dist/lang_server_{linux|mac|windows}.sh\"],\n            \"scopes\": [\"source.java\"],\n            \"syntaxes\": [\"Packages/Java/Java.sublime-syntax\"],\n            \"languageId\": \"java\"\n        }\n    }\n}\n```\n\n## [Issues](https://github.com/georgewfraser/java-language-server/issues)\n\n## Features\n\n### Javadoc\n\n![Javadoc](images/Javadoc.png)\n\n### Signature help\n\n![Signature help](images/SignatureHelp.png)\n\n### Autocomplete symbols (with auto-import)\n\n![Auto import 1](images/AutoImport1.png)\n\n![Auto import 2](images/AutoImport2.png)\n\n### Autocomplete members\n\n![Autocomplete members](images/AutocompleteMembers.png)\n\n### Go-to-definition\n\n![Goto 1](images/Goto1.png)\n\n![Goto 2](images/Goto2.png)\n\n### Find symbols\n\n![Find workspace symbols](images/FindWorkspaceSymbols.png)\n\n![Find document symbols](images/FindDocumentSymbols.png)\n\n### Lint\n\n![Error highlight](images/ErrorHighlight.png)\n\n### Type information on hover\n\n![Type hover](images/TypeHover.png)\n\n### Find references\n\n![Find references 1](images/FindReferences1.png)\n\n![Find references 2](images/FindReferences2.png)\n\n### Debug\n\n![Debug test](images/DebugTest.png)\n\n## Usage\n\nThe language server will provide autocomplete and other features using:\n* .java files anywhere in your workspace\n* Java platform classes\n* External dependencies specified using `pom.xml`, Bazel, or [settings](#Settings)\n\n## Settings\n\nIf the language server doesn't detect your external dependencies automatically, you can specify them using [.vscode/settings.json](https://code.visualstudio.com/docs/getstarted/settings)\n\n```json\n{\n    \"java.externalDependencies\": [\n        \"junit:junit:jar:4.12:test\", // Maven format\n        \"junit:junit:4.12\" // Gradle-style format is also allowed\n    ]\n}\n```\n\nIf all else fails, you can specify the Java class path and the locations of\nsource jars manually:\n\n```json\n{\n    \"java.classPath\": [\n        \"lib/some-dependency.jar\"\n    ],\n    \"java.docPath\": [\n        \"lib/some-dependency-sources.jar\"\n    ]\n}\n```\n\nYou can generate a list of external dependencies using your build tool:\n* Maven: `mvn dependency:list`\n* Gradle: `gradle dependencies`\n\nThe 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:\n* Maven\n  * `mvn dependency:resolve` for compilation and autocomplete\n  * `mvn dependency:resolve -Dclassifier=sources` for inline Javadoc help\n* Gradle\n  * `gradle dependencies` for compilation and autocomplete\n  * Include `classifier: sources` in your build.gradle for inline Javadoc help, for example:\n    ```\n    dependencies {\n        testCompile group: 'junit', name: 'junit', version: '4.+'\n        testCompile group: 'junit', name: 'junit', version: '4.+', classifier: 'sources'\n    }\n    ```\n\n## Design\n\nThe Java language server uses the [Java compiler API](https://docs.oracle.com/javase/10/docs/api/jdk.compiler-summary.html) to implement language features like linting, autocomplete, and smart navigation, and the [language server protocol](https://github.com/Microsoft/vscode-languageserver-protocol) to communicate with text editors like VSCode.\n\n### Incremental updates\n\nThe 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:\n\n```java\nclass Printer {\n    void printFoo() {\n        System.out.println(\"foo\");\n    }\n    void printBar() {\n        System.out.println(\"bar\");\n    }\n    void main() {\n        print // Autocomplete here\n    }\n}\n```\n\nNone 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:\n\n```java\nclass Printer {\n    void printFoo() {\n\n    }\n    void printBar() {\n\n    }\n    void main() {\n        print // Autocomplete here\n    }\n}\n```\n\nFor most requests, the vast majority of code can be erased, dramatically speeding up compilation.\n\n## Logs\n\nThe java service process will output a log file to stderr, which is visible in VSCode using View / Output, under \"Java\".\n\n## Contributing\n\n### Installing\n\nBefore installing locally, you need to install prerequisites: npm, maven, protobuf. For example on Mac OS, you can install these using [Brew](https://brew.sh):\n\n    brew install npm maven protobuf\n\nYou also need to have [Java 13](https://www.oracle.com/technetwork/java/javase/downloads/index.html) installed. Point the `JAVA_HOME` environment variable to it. For example, on Mac OS:\n\n    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/\n\nAssuming you have these prerequisites, you should be able to install locally using:\n\n    npm install -g vsce\n    npm install\n    ./scripts/build.sh\n\n### Editing\n\nPlease run ./configure before your first commit to install a pre-commit hook that formats the code.\n","funding_links":[],"categories":["Tooling"],"sub_categories":["Editors"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgewfraser%2Fjava-language-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeorgewfraser%2Fjava-language-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeorgewfraser%2Fjava-language-server/lists"}