Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 57 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<!--
Copyright (c) 2023-2025, Oracle and/or its affiliates.

Copyright (c) 2023-2025, Oracle and/or its affiliates.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

Expand All @@ -28,12 +29,12 @@
[![Build Status](https://img.shields.io/github/actions/workflow/status/oracle/javavscode/main.yml?branch=main&style=for-the-badge&logo=github)](https://github.com/oracle/javavscode/actions?query=workflow:Java%20Platform%20Support%20for%20Visual%20Studio%20Code)
[![License](https://img.shields.io/github/license/oracle/javavscode?style=for-the-badge&logo=apache)](https://github.com/oracle/javavscode/blob/main/LICENSE.txt)

Java 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.
Java 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
1. VS Code Tips
- To install and update extensions refer to [extensions](https://code.visualstudio.com/docs/getstarted/extensions).
- To install and update extensions, refer to [Use extensions in Visual Studio Code](https://code.visualstudio.com/docs/getstarted/extensions).
- Search for a command by opening the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) and typing the keywords.
- Keyboard Shortcut:
- Windows/Linux: `Ctrl+Shift+P`
Expand All @@ -46,7 +47,7 @@ Java Platform extension from Oracle brings full featured development support (ed
- The extension requires JDK 17 or newer to run.
- Optionally, set a different JDK to compile and run projects in the `Open Settings | Jdk › Project: Jdkhome` setting.
- By default, the __jdk.jdkhome__ setting is used.
- Projects can run on JDK 8 and above.
- Projects can run on JDK 8 and above.
- For more information, see the section [Selecting the JDK](#selecting-the-jdk).
3. Use any one of the following ways to start coding, compiling and debugging in Java.
- Simply create a new Java class with `main` method.
Expand All @@ -55,14 +56,14 @@ Java Platform extension from Oracle brings full featured development support (ed
- Open the folder with existing __Maven__ or __Gradle__ project files (_pom.xml_ or _build.gradle, gradle.properties_).

## Supported Actions
In the VS Code command palette :
In the VS Code command palette:
* __Java: New Project...__ allows creation of new Maven or Gradle project
* __Java: New File from Template...__ add various files to currently selected open project. Files are:
* __Java: New File from Template...__ adds various files to the currently selected open project. Files are:
* Java - broad selection of various predefined Java classes
* Unit tests - JUnit and TestNG templates for test suites and test cases
* Other - various templates for Javascript, JSON, YAML, properties, ... files
* __Java: Create New Notebook...__ command to create a new [Java notebook](#interactive-java-notebooks)(`.ijnb` file)
* __Java: Open JShell...__ command to open [JShell](#jshell) .
* __Java: Create New Notebook...__ command to create a new [Java notebook](#interactive-java-notebooks) (`.ijnb` file)
* __Java: Open JShell...__ command to open [JShell](#jshell).
* __Java: Compile Workspace__ - invoke Maven or Gradle build
* __Java: Clean Workspace__ - clean Maven or Gradle build
* __Download, install and Use JDK__ - allows download and installation of JDK binaries
Expand All @@ -72,50 +73,50 @@ In the VS Code command palette :
* __Java: Go To Test/Tested Class__ - Navigates to the corresponding test or source class file

## Project Explorer
Project 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.
Project 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.
![Project Explorer](vscode/images/project-explorer.png)

## Interactive Java Notebooks
### Introduction
* Experience interactive coding with Java notebooks.
Use the __Java: Create New Notebook...__ command to create a new Java notebook(`.ijnb` file)
![Java Notebook](vscode/images/java_notebook.gif)
* Add code snippets with `+ Code` button and document with markdown cells with `+ Markdown`.
* Double click on a cell to edit and hit `Esc` when done.
* Experience interactive coding with Java notebooks. Use the __Java: Create New Notebook...__ command to create a new Java notebook (`.ijnb` file)
![Java Notebook](vscode/images/java_notebook.gif)
* Add code snippets with `+ Code` button and document with markdown cells using the `+ Markdown` button.
* Double-click on a cell to edit and press `Esc` when done.
* Jupyter-style notebooks let you combine Java code snippets with markdown-formatted text cells.
* Run individual code cells or execute the entire notebook.
* Can save outputs alongside code cells.
* Sharing notebooks
* Share as `.ijnb` files for use with Oracle Java extension.
* Rename with `.ipynb` for viewing in other IDEs Jupyter etc.
* Download the [sample notebooks](https://github.com/oracle/javavscode/blob/main/samples/notebooks) and open in VSCode to get started.
* Save outputs alongside code cells.
* **Sharing notebooks:**
* Share as `.ijnb` files for use with the Oracle Java extension.
* Rename with a `.ipynb` extension for viewing in other IDEs, such as Jupyter.
* Download the [sample notebooks](https://github.com/oracle/javavscode/blob/main/samples/notebooks) and open them in VS Code to get started.

### Java Notebooks for Java Projects
* Document Java projects with interactive Java notebooks.
* Open/Create a Java notebook in your workspace folder loaded with classes from your project.
* Open or create a Java notebook in your workspace folder loaded with classes from your project.
![Java Notebook For Project](vscode/images/project_notebook.gif)
* Use `Project Context` options incase you want to change to a different project context .
* Use the `Project Context` options to switch to a different project context.
![Switch Project Context](vscode/images/project_context.png)
* Provide code snippets, markdown explanations, and expected outputs.

### Notebook Configurations
* Following configuration settings are available
* `jdk.notebook.classpath`
* `jdk.notebook.modulepath`
* `jdk.notebook.addmodules`
* `jdk.notebook.enablepreview`
* `jdk.notebook.implicitimports`
* Note : These settings *override* any settings inferred from project context 
The following configuration settings are available:
* `jdk.notebook.classpath`
* `jdk.notebook.modulepath`
* `jdk.notebook.addmodules`
* `jdk.notebook.enablepreview`
* `jdk.notebook.implicitimports`

These settings *override* settings inferred from project context 

## JShell
* Use the __Java: Open JShell...__ command to open JShell .
* Use the __Java: Open JShell...__ command to open JShell.
* Project classes from currently open project are automatically loaded.
![JShell](vscode/images/jshell.gif)

## Debugger and Launch Configurations
Language Server __Java+ ...__ launch configuration supports debugging and running Java applications using JDK11 or newer.
1. The launch configuration (debugger) is invoked when `Run main | Debug main` codelens is selected in the code.
2. Or __Java+...__ is selected in __Run and Debug__ activity panel.
2. Or __Java+...__ is selected in __Run and Debug__ activity panel.
![Debug configurations](vscode/images/debuggers.png)
### Launch Configurations
* __Launch Java App__ - Debug or Run current Java project
Expand All @@ -127,21 +128,22 @@ Language Server __Java+ ...__ launch configuration supports debugging and runnin
Default launch configurations provided by Language Server can modified in `launch.json` file.

### Run Configurations panel
Program arguments, VM options, environment 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 `launch.json` (which still takes precedence).
Program arguments, VM options, environment variables, etc., can be set in the Run Configuration panel as part of Explorer. The panel is sufficient for all typical use-cases Java programmer faces. Only advanced, expert scenarios may require touching of `launch.json` (which still takes precedence).
![Run Configuration](vscode/images/run_config.png)

## JDK Downloader
If 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.
![JDK Downloader](vscode/images/jdk_downloader.png)
You can also access the JDK downloader through the "Download, install, and Use JDK" option in the command palette.
![JDK Downloader](jdk_downloader.png)

## Enabling Java Preview Features
When using preview features use the quick fix action option to easily enable them.

![Enable Preview](vscode/images/enable_preview.gif)
## Supported Refactorings

Class level refactorings as well as variable refactorings are supported in VSCode via Oracle Java Platform extension. See following screenshots:
Class level refactorings as well as variable refactorings are supported in VS Code via Oracle Java Platform extension. See following screenshots:

### Source Action ... context menu
![Class Source Actions](vscode/images/Source_actions.png)
Expand All @@ -155,16 +157,16 @@ Class level refactorings as well as variable refactorings are supported in VSCod
### Surround with refactorings
![Surrond with Refactorings](vscode/images/Surrond_With_refactorings.png)

Some refactorings are two steps with like __Generate Override method__ ... where method to be overriden is selected in 2nd step:
Some refactorings are two steps with like __Generate Override method__ ... where method to be overriden is selected in 2nd step:

![Override refactoring](vscode/images/Override_refactoring.png)

### Change Method Parameters refactoring
Change method parameters refactoring is provided using dedicated form allowing to change, add, move, remove method parameters.
Change method parameters refactoring is provided using dedicated form allowing to change, add, move, remove method parameters.
![Change method parameters refactoring](vscode/images/change_method_params.png)

### Move Members Refactoring
Move members refactoring provides dedicated form as well.
Move members refactoring provides dedicated form as well.
![Move members refactoring](vscode/images/move_refactoring.png)

### Some of supported refactorings:
Expand All @@ -186,37 +188,37 @@ Move members refactoring provides dedicated form as well.
* Constructor and method argument refactoring

## Formatter Preferences
Easily update default formatter preferences by adjusting a simple configuration option to tailor settings according to specific needs.
Easily update default formatter preferences by adjusting a simple configuration option to tailor settings according to specific needs.

Go to VSCode `Open Settings | Extensions | Java` and set `Jdk › Format: Settings Path:` option to the formatter preferences file.
Go to VS Code `Open Settings | Extensions | Java` and set `Jdk › Format: Settings Path:` option to the formatter preferences file.

Please refer to [Java formatting preferences](https://github.com/oracle/javavscode/wiki/Java-formatting-preferences) wiki for more info.

## Hints Preferences
Easily update default hint preferences by adjusting a simple configuration option to tailor hint preferences to specific needs.

Go to VSCode `Open Settings | Extensions | Java` and set `Jdk › Hints: Preferences:` option to the xml hint preferences file.
Go to VS Code `Open Settings | Extensions | Java` and set `Jdk › Hints: Preferences:` option to the xml hint preferences file.

## Organize Imports
Out 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 `Open Settings | Extensions | Java` and search for _Jdk_ to set `Jdk > Java > Imports:` options:
Go to VS Code `Open Settings | Extensions | Java` and search for _Jdk_ to set `Jdk > Java > Imports:` options:
* `Count For Using Star Import` - Class count to use a star-import, 999 is the default value
* `Count For Using Static Star Import` - Members count to use a static star-import, 999 is the default value
* `Groups` - Groups of import statements (specified by their package prefixes) and their sorting order. Import statements within a group are ordered alphabetically

And `Open Settings | Extensions > Java > On Save: Organize Imports` - Enable organize imports action on a document save

## JavaDoc smart editing
When adding JavaDoc to code Oracle Java Platform extension assists by suggesting to insert preformatted and prepopulated JavaDoc comment. Type `/**` above method signature and IDE offers to complete the JavaDoc. The action creates JavaDoc comment with all arguments prepared.
When adding JavaDoc to code Oracle Java Platform extension assists by suggesting to insert preformatted and prepopulated JavaDoc comment. Type `/**` above method signature and IDE offers to complete the JavaDoc. The action creates JavaDoc comment with all arguments prepared.
![JavaDoc Completion](vscode/images/javadoc.png)

## Test Explorer
Oracle 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.
Oracle 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.
![Test Explorer](vscode/images/Test_explorer.png)

### Localization support
Oracle Java Platform extension provides localization support for _Japanese_ and _Simplified Chinese_.
Oracle Java Platform extension provides localization support for _Japanese_ and _Simplified Chinese_.
To switch language `Go to command Palette->Configure display language` select `ja` for _Japanese_ or `zh-cn` for _Simplified Chinese_


Expand All @@ -236,19 +238,19 @@ As soon as one of the settings is changed, the Language Server is restarted.
This 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 `Open Settings | Jdk > Advanced > Disable: Nbjavac` and enable the checkbox.

Step-2: Set the JDK in `Open Settings | Jdk: Jdkhome` to point to the early access JDK path.
Step-2: Set the JDK in `Open Settings | Jdk: Jdkhome` to point to the early access JDK path.

## Troubleshooting
If 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 `View | Command Palette | Delete oracle java extension cache for this workspace`.

## Workspace
The 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.

## Known Issue
## Known Issues
1. If an action has been applied to the Maven `pom.xml` file through the extension, such as enabling a preview feature or adding a test runner framework, subsequent compile or run operations may fail. To resolve this issue, please follow the steps below:
1. Check the `pom.xml` file for any duplicated tags.
2. If duplicated tags are found, remove the extra tags and attempt to compile again.
3. Add the `--enable-preview` VM argument to the *exec-maven-plugin* or *maven-surefile-plugin* configurations if they are used execution or test runs.
3. Add the `--enable-preview` VM argument to the *exec-maven-plugin* or *maven-surefile-plugin* configurations if they are used for execution or test runs.
2. The *Project: Test Project* command executes the project's tests but does not update the Testing or the Tests Results panels. The test output is present only in the Terminal or Debug Console panel.

## Telemetry
Expand Down Expand Up @@ -277,5 +279,5 @@ Please consult the [security guide](https://github.com/oracle/javavscode/blob/ma

Copyright (c) 2023-2025 Oracle and/or its affiliates.

Oracle Java Platform Extension for Visual Studio Code is licensed under [Apache 2.0 License](https://github.com/oracle/javavscode/blob/main/LICENSE.txt).
Oracle Java Platform Extension for Visual Studio Code is licensed under [Apache 2.0 License](https://github.com/oracle/javavscode/blob/main/LICENSE.txt).
The [THIRD_PARTY_LICENSES](./THIRD_PARTY_LICENSES.txt) file contains third party notices and licenses.