redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.08k stars 441 forks source link
java language-server vscode-extension

Language support for Java ™ for Visual Studio Code

Visual Studio Marketplace Installs Join the chat at https://gitter.im/redhat-developer/vscode-java Build Status License

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

Quick Start

  1. Install the Extension
  2. 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.
  3. Optionally, download and install a Java Development Kit for your project (Java 1.8 or above is supported). See Project JDKs for more details
  4. Extension is activated when you first access a Java file
    • Recognizes projects with Maven or Gradle build files in the directory hierarchy.

Features

 screencast

To launch and debug your Java programs, it's recommended you install Java Debug Extension for Visual Studio Code.

See the changelog for the latest release. You might also find useful information in the project Wiki.

Setting the JDK

Java Tooling JDK

Now that Java extension will publish platform specific versions, it will embed a JRE for supported platforms such as win32-x64, linux-x64, linux-arm64, darwin-x64, darwin-arm64. The embedded JRE is used to launch the Language Server for Java. Users are only responsible for configuring Project JDKs to compile your Java projects.

The following part is only kept for the universal version without embedded JRE.

The tooling JDK will be used to launch the Language Server for Java. And by default, will also be used to compile your projects. Java 17 is the minimum required version.\ \ The path to the Java Development Kit can be specified by the java.jdt.ls.java.home setting in VS Code settings (workspace/user settings). If not specified, it is searched in the following order until a JDK meets current minimum requirement.

  • the JDK_HOME environment variable
  • the JAVA_HOME environment variable
  • on the current system path

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.

Available commands

The following commands are available:

Supported VS Code settings

The following settings are supported:

New in 1.37.0

Semantic Highlighting

Semantic Highlighting fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience a few minor issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server, when opening a new file or when typing. Semantic highlighting can be disabled for all languages using the editor.semanticHighlighting.enabled setting, or for Java only using language-specific editor settings.

Troubleshooting

  1. Check the status of the language tools on the lower right corner (marked with A on image below). It should show ready (thumbs up) as on the image below. You can click on the status and open the language tool logs for further information in case of a failure.

 status indicator

  1. Read the troubleshooting guide for collecting informations about issues you might encounter.

  2. Report any problems you face to the project.

Contributing

This is an open source project open to anyone. Contributions are extremely welcome!

For information on getting started, refer to the CONTRIBUTING instructions.

Continuous Integration builds can be installed from http://download.jboss.org/jbosstools/jdt.ls/staging/. Download the most recent java-<version>.vsix file and install it by following the instructions here. Stable releases are archived under http://download.jboss.org/jbosstools/static/jdt.ls/stable/.

Also, you can contribute your own VS Code extension to enhance the existing features by following the instructions here.

Feedback

License

EPL 2.0, See LICENSE for more information.