Skip to main content
Back to Extensions Directory
coc.nvim fallback icon

Java language extension for coc.nvim

Installation CommandVim prompt
:CocInstall coc-java
GitHub owner
Neoclide
Version
v1.56.0
npm package
coc-java
Requirements
coc >=0.0.82
License
EPL-1.0
Repository
GitHub
npm latest published 2026-08-22Registry checked 2026-08-31Registry summary

A practical first workflow

Start with one small saved Java project to distinguish a language-server startup problem from an import or classpath problem. coc-java starts Eclipse JDT Language Server; the Java executable running that server and the JDK selected for your project can be different.

Check the tooling JDK before the project

Install with :CocInstall coc-java. For coc-java 1.56.0, use JDK 21 or newer for the normal language-server startup; the experimental java.jdt.ls.javac.enabled mode requires 23 or newer. The extension can discover installed runtimes or download a runtime on supported platforms. For a reproducible setup, set the JDK home explicitly in :CocConfig, replacing the path below with an installed JDK directory, not its bin/java executable.

coc-settings.json
1{
2 "java.jdt.ls.java.home": "/absolute/path/to/jdk-23",
3 "java.configuration.runtimes": [
4 {
5 "name": "JavaSE-23",
6 "path": "/absolute/path/to/jdk-23",
7 "default": true
8 }
9 ]
10}

Merge these settings into your existing configuration, then restart with :CocRestart. java.jdt.ls.java.home selects the tooling runtime; java.configuration.runtimes maps project Java versions to installed JDKs. A terminal’s java -version alone cannot prove which one the extension selected. Inspect :CocCommand java.open.clientLog for the resolved runtime paths.

Import a minimal Maven project

Create a new directory containing the following pom.xml and src/main/java/example/Main.java. Save both files before opening the Java buffer. This example uses JDK 23; if you use JDK 21, change the runtime name, its path, and both Maven version values to match. A mismatch can leave an execution-environment warning even when navigation works.

pom.xml
1<project xmlns="http://maven.apache.org/POM/4.0.0">
2 <modelVersion>4.0.0</modelVersion>
3 <groupId>example</groupId>
4 <artifactId>coc-java-demo</artifactId>
5 <version>1.0-SNAPSHOT</version>
6 <properties>
7 <maven.compiler.source>23</maven.compiler.source>
8 <maven.compiler.target>23</maven.compiler.target>
9 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10 </properties>
11</project>
src/main/java/example/Main.java
1package example;
2 
3public class Main {
4 static int twice(int value) {
5 return value * 2;
6 }
7 
8 public static void main(String[] args) {
9 int count = "three";
10 System.out.println(twice(count));
11 }
12}

Launch the editor from the directory containing pom.xml: nvim src/main/java/example/Main.java. Check :set filetype? reports java. Allow project import to finish; :CocCommand java.show.server.task.status shows server jobs. If the project was not imported, run :CocCommand java.project.import.command. A first Maven import can download build plugins even when the project declares no dependencies; keep java.import.maven.offline.enabled disabled until the required artifacts are cached.

Verify a diagnostic and a definition jump

Run :CocDiagnostics and look for the incompatible assignment of "three" to int. Change it to 3, save, and confirm that diagnostic clears. Then place the cursor on twice in the println call and run :call CocAction('jumpDefinition'); it should move to the method declaration in this file. These checks exercise analysis and navigation after import.

  • If no Java commands are available, check :CocList extensions, java.enabled and :CocOpenLog for activation errors.
  • If the server cannot start, inspect java.open.clientLog and java.open.serverLog. Fix a missing or unsupported JDK before changing the project dependencies.
  • If the server starts but reports an incomplete classpath, check the imported root and build descriptor. After changing pom.xml, use :CocCommand java.projectConfiguration.update. java.server.launchMode should be Standard for this full-project exercise; LightWeight provides syntax features only.
  • Use :CocCommand java.clean.workspace only after preserving useful logs and checking the JDK and project configuration; it rebuilds language-server workspace state and is not a substitute for correcting those inputs.

Verified on macOS with Neovim 0.12.4, JDK 23.0.2 and coc-java 1.56.0: Maven import completed, the assignment diagnostic appeared, changing the value to 3 cleared all diagnostics, and the definition action jumped to line 4. Runtime requirements were checked in the version’s startup code; commands and settings in its published manifest. This checks editor behavior, not an application build or Gradle import.

Site-authored guidance reviewed on 2026-09-22. Content sources and maintainers · Choose extension responsibilities

Published Package Summary

coc-java

Fork of vscode-java to works with coc.nvim.

Provides Java ™ language support via Eclipse ™ JDT Language Server, which utilizes Eclipse ™ JDT, M2Eclipse and Buildship.

Quick Start

  1. Install this extension by run command:
:CocInstall coc-java
  1. On the following platforms, the extension should activate without any setup : win32-x64, darwin-x64, darwin-arm64, linux-x64, linux-arm64.
    If on another platform, or using the "universal" version, you can set a Java Development Kit. It must be Java 17 or above.

  2. Optionally, download and install a Java Development Kit for your project (Java 1.5 or above is supported). See Project JDKs for more details

  3. Extension is activated when you first access a Java file

    • Recognizes projects with Maven or Gradle build files in the directory hierarchy.

Note: this extension comes with bunlded jdt.ls from 1.14.0, the same as vscode-java.

Project JDKs

If you need to compile your projects against a different JDK version, it's recommended you configure the java.configuration.runtimes property in your user settings, eg:

"java.configuration.runtimes": [
  {
    "name": "JavaSE-1.8",
    "path": "/path/to/jdk-8",
  },
  {
    "name": "JavaSE-11",
    "path": "/path/to/jdk-11",
  },
  {
    "name": "JavaSE-23",
    "path": "/path/to/jdk-23",
    "default": true
  },
]

The default runtime will be used when you open standalone Java files.

Features

  • Supports code from Java 1.5 to Java 23
  • Maven pom.xml project support
  • Gradle project support (with experimental Android project import support)
  • Standalone Java files support
  • As-you-type reporting of parsing and compilation errors
  • Code completion
  • Code/Source actions / Refactoring
  • Javadoc hovers
  • Organize imports
    • triggered manually (by :call CocAction('organizeImport')) or on save
    • when pasting code into a java file with Ctrl+Shift+v (Cmd+Shift+v on Mac)
  • Type search
  • Code outline
  • Code folding
  • Code navigation
  • Code lens (references/implementations)
  • Highlights
  • Code formatting (on-type/selection/file)
  • Code snippets
  • Annotation processing support (automatic for Maven projects)
  • Semantic selection
  • Diagnostic tags
  • Call Hierarchy
  • Type Hierarchy (:CocCommand java.action.showTypeHierarchy)
  • Share indexes (enabled by configuration java.sharedIndexes.enabled)

See the changelog for the latest release.

Semantic Highlighting

To enable semantic highlighting support, use configuration:

"semanticTokens.enable": true,

For java filetype only, use:

"[java]": {
  "semanticTokens.enable": true,
}

Checkout :h coc-configuration-scope.

Buffer not work

The jdt.ls requires buffer saved to disk to work, save the buffer by :w command and reload it by :e command in your vim. Or create the file on disk before buffer create.

Compiler warnings

To customize compiler warnings, create the file root_project/.settings/org.eclipse.jdt.core.prefs with values presented at https://help.eclipse.org/neon/topic/org.eclipse.jdt.doc.isv/reference/api/org/eclipse/jdt/core/JavaCore.html

"Classpath is incomplete" warning

See https://github.com/redhat-developer/vscode-java/wiki/%22Classpath-is-incomplete%22-warning

Troubleshooting

  • Text OK would be in your statusline when jdt.ls is ready and you have statusline integration with coc.nvim. (could be configured by java.jdt.ls.statusIcons)
  • Run :CocOpenLog to get unexpected errors thrown by coc.nvim extensions.
  • Enable verbose trace for jdt.ls by add "java.trace.server": "verbose" in your settings file, then check output by :CocCommand java.open.output
  • Run :CocCommand java.open.serverLog to open log of jdt.ls.
  • Run :CocCommand java.open.clientLog to open extension Log File.
  • Try :CocCommand java.clean.workspace to clean workspace cache.

Feedback

License

EPL 1.0, See LICENSE for more information.

Read the complete README
  • Java language extension for coc.nvim
Activation Events
  • onLanguage:java
  • workspaceContains:pom.xml
  • workspaceContains:*/pom.xml
  • workspaceContains:build.gradle
  • workspaceContains:*/build.gradle
  • workspaceContains:settings.gradle
  • workspaceContains:*/settings.gradle
  • workspaceContains:build.gradle.kts
  • workspaceContains:*/build.gradle.kts
  • workspaceContains:settings.gradle.kts
  • workspaceContains:*/settings.gradle.kts
  • workspaceContains:.classpath
  • workspaceContains:*/.classpath
Developer Resources

Want to build, test, or contribute to coc.nvim extensions? Explore our official SDK and testing toolkits.

Open Developer Guide

Version History

Published with coc-java@1.56.0 as history.md.

Open source file

Change Log

1.56.0 (2026-08-22)

Major features

  • Synchronize Java language support with vscode-java 1.56.0, including Java 24-26 runtime definitions, newer JDT LS quick fixes and cleanups, and JSpecify null analysis defaults.
  • Add an extended Java outline that includes inherited members and supports direct navigation.
  • Support snippet-based workspace edits and whole-expression Java postfix completions.
  • Improve JDT LS startup and project discovery across Maven and Gradle multi-module workspaces, ARM hosts, Termux, Windows, and older coc.nvim versions, with a stdio transport fallback.

New settings

  • java.transport: Select pipe or stdio transport for JDT LS.
  • java.completion.lazyResolveTextEdit.enabled: Lazily resolve completion text edits.
  • java.codeGeneration.generateCommentsInMarkdown: Generate Markdown-style Javadoc comments.
  • java.templates.newFile.enabled: Control automatic type and package generation for new Java files.
  • java.templates.methodBody: Customize generated unimplemented method bodies.
  • java.templates.preferPackagePrivateVisibility: Prefer package-private visibility for new top-level types.
  • java.templates.methodBodySuper: Customize generated overriding method bodies that call super.
  • java.templates.catchBody: Customize generated catch block bodies.
  • java.hover.javadoc.enabled: Control Javadoc display in hovers.
  • java.referencesCodeLens.includeFields: Include fields in references CodeLens.
  • java.symbols.includeGeneratedCode: Include generated code in document symbols.
  • java.inlayHints.parameterNames.suppressWhenSameNameNumbered: Suppress redundant numbered parameter-name hints.
  • java.inlayHints.variableTypes.enabled: Show inferred variable type hints.
  • java.inlayHints.parameterTypes.enabled: Show inferred lambda parameter type hints.
  • java.inlayHints.formatParameters.enabled: Show format-specifier parameter hints.
  • java.search.scope: Select all, main, or projectOnly for references, call hierarchy, and workspace symbol searches.
  • java.jdt.ls.aspectjSupport.enabled: Enable AspectJ support for Gradle projects.
  • java.jdt.ls.kotlinSupport.enabled: Enable experimental Kotlin support for Gradle projects.
  • java.jdt.ls.scalaSupport.enabled: Enable experimental Scala support for Gradle projects.
  • java.jdt.ls.groovySupport.enabled: Enable experimental Groovy support for Gradle projects.
  • java.jdt.ls.appcds.enabled: Control experimental AppCDS startup optimization.

New commands

  • java.runtimes.add: Add Java Runtime.
  • java.change.searchScope: Change Java Search Scope.
  • java.action.copyFullyQualifiedName: Copy Fully Qualified Name.
  • java.action.showExtendedOutline: Open Extended Outline.

1.15.0 (2023-09-20)

  • performance - Skip generated methods when calculating document symbols.
  • performance - Make the debounce adaptive for the publish diagnostic job.
  • performance - Only perform context sensitive import rewrite when resolving completion items.
  • performance - Extension activation should not depend on language server being started.
  • enhancement - Support "extract interface" refactoring.
  • enhancement - Add "Convert String concatenation to Text Block" quick assist.
  • enhancement - Add clean up for using try-with-resource.
  • enhancement - Enable formatting support in syntax server.
  • enhancement - Add option to configure behaviour when mojo execution metadata not available.
  • enhancement - Add option to permit usage of test resources of a Maven project as dependencies within the compile scope of other projects.
  • bug fix - Change default generated method stub to throw exception.
  • bug fix - Prevent the paste handler for missing imports from generating overlapping text edits.
  • bug fix - Reference search doesn't work for fields in JDK classes.
  • bug fix - Paste event handling blocks pasting while project loading.
  • bug fix - Avoid generating boilerplate code repeatedly in new Java file.
  • bug fix - Completion results should include filtered (excluded) types if they are also present in the import declarations.
  • bug fix - Fix type hierarchy regression since VS Code 1.75.1.
  • bug fix - Re-publish diagnostics for null analysis configuration change when auto-build is disabled.
  • bug fix - Dependency Analytics extension popup shoud respect user choice.
  • bug fix - Only do full build for a configuration change when auto-build is enabled.
  • bug fix - The command to upgrade gradle should check for cancellation prior to updating metadata files.
  • bug fix - Fix incorrect ordering of completion items that use a decorator.
  • bug fix - Reduce the amount of logging from org.apache.http bundles.
  • documentation - Clarify the README quick start instructions.

1.14.1

  • Fix background task not finish during completion by avoid selection range request.
  • Fix an exception caused by undefined kind of WorkspaceSymbol on resolve.

1.14.0 (2023-01-29)

  • Synchronize with vscode-java@1.14.0.
  • Standard launch mode is used by default, because bugs with Hybrid mode.