Java Platform Extension for Visual Studio CodeJava Platform extension from Oracle brings full featured development support (edit-compile-debug & test cycle) to VS Code. It also offers support for Maven and Gradle projects. Applications using JDK 8 and above are supported. Getting Started
Supported ActionsIn the VS Code command palette :
Project ExplorerProject Explorer provides an overview of logical project structure, groups sources together and greatly simplifies Java package structure exploration. Project Explorer is an addition to the classical workspace explorer. Use it to build, test, execute and operate your Maven and Gradle Java projects. Localisation supportOracle Java Platform extension provides localisation support for Japanese and Simplified Chinese.
To switch language Debugger and Launch ConfigurationsLanguage Server Java+ ... launch configuration supports debugging and running Java applications using JDK11 or newer.
Launch Configurations
Default launch configurations provided by Language Server can modified in Run Configurations panelProgram arguments, VM options, evironment variables,... can be set in Run Configuration panel a part of Explorer. The panel is sufficient for all typical use-cases Java programmer faces. Only advanced, expert scenarios may require touching of JDK DownloaderIf the system does not detect any JDK, the extension will offer a downloader and setup prompt to help you set up a JDK. This setup provides options for Oracle JDK, OpenJDK, and allows you to choose from any installed JDK on your system.
Alternatively, you can manually specify the path to JDK binaries by utilizing the JDK downloader.
You can also access the JDK downloader through the "Download, install, and Use JDK" option in the command palette. Enabling Java Preview FeaturesWhen using preview features use the quick fix action option to easily enable them. Supported RefactoringsClass level refactorings as well as variable refactorings are supported in VS Code via Oracle Java Platform extension. See following screenshots: Source Action ... context menuIntroduce refactorings available via Show Code actions light bulbMore Refactorings available also using Refactor... context menuSurround with refactoringsSome refactorings are two steps with like Generate Override method ... where method to be overriden is selected in 2nd step: Change Method Parameters refactoringChange method parameters refactoring is provided using dedicated form allowing to change, add, move, remove method parameters. Move Members RefactoringMove members refactoring provides dedicated form as well. Some of supported refactorings:
Formatter PreferencesEasily update default formatter preferences by adjusting a simple configuration option to tailor settings according to specific needs. Go to VSCode Please refer to Java formatting preferences wiki for more info. Hints PreferencesEasily update default hint preferences by adjusting a simple configuration option to tailor hint preferences to specific needs. Go to VSCode Organize ImportsOut of the box support for organizing imports in Java sources is available. It removes unused imports, groups imports by packages and updates your imports whenever a file is saved. In addition to the defaults, there is a rich set of configuration options. Go to VSCode
And JavaDoc smart editingWhen adding JavaDoc to code Oracle Java Platform extension assists by suggesting to insert preformatted and prepopulated JavaDoc comment. Type Test ExplorerOracle Java Platform extension provides Test Explorer view which allows to run all tests in a project, examine the results, go to source code and run particular test. Selecting the JDKThe JDK to build, run and debug projects is being searched in the following locations:
As soon as one of the settings is changed, the Language Server is restarted. How to use JDK early access buildsThis setup makes it easier to experiment with early access JDK builds. Follow these steps to enable the use of an early access JDK:
Step-1: Navigate to Step-2: Set the JDK in TroubleshootingIf your extension is not starting and throwing some error like no JDK found even if you have a working JDK installed in your machine, then you can try deleting cache for the workspace using WorkspaceThe extension will analyze the content of the opened workspace, and relevant other files. If the workspace contains a lot of data, this may take a long time. It is therefore recommended to avoid adding unnecessarily big folders in a workspace. Specifically, it is not recommended to open user's home directory as a part of the workspace. ContributingThis project welcomes contributions from the community. Before submitting a pull request, please review our contribution guide SecurityPlease consult the security guide for our responsible security vulnerability disclosure process LicenseCopyright (c) 2024 Oracle and/or its affiliates. Oracle Java Platform Extension for Visual Studio Code is licensed under Apache 2.0 License. The THIRD_PARTY_LICENSES file contains third party notices and licenses. |