Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

We welcome contributions, and request you follow these guidelines.

> Note: Starting with the [0.1.12 early release](https://github.com/OpenLiberty/liberty-tools-vscode/releases/tag/0.1.12), Java 17 is required to run Liberty Tools for Visual Studio Code.
> Note: Java 21 or later is required to run Liberty Tools for Visual Studio Code.

- [Raising issues](#raising-issues)
- [Legal](#legal)
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developing Liberty Tools for Visual Studio Code

> Note: Starting with the [0.1.12 early release](https://github.com/OpenLiberty/liberty-tools-vscode/releases/tag/0.1.12), Java 17 is required to run Liberty Tools for Visual Studio Code.
> Note: Java 21 or later is required to run Liberty Tools for Visual Studio Code.

- [Build Liberty Tools for Visual Studio Code](#build-liberty-tools-for-visual-studio-code)
- [Language Servers](#language-servers)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Liberty Tools for Visual Studio Code

<!-- Match the VSCode and Java version in #requirements, and user-guide.md -->
> Note: Requires **Visual Studio Code 1.78.0** or later, and **Java 17** or later.
> Note: Requires **Visual Studio Code 1.78.0** or later, and **Java 21** or later.
>
> This page provides an overview of Liberty Tools for Visual Studio Code.
> For minimum requirements information and detailed instructions on how to use Liberty Tools, check the [user-guide](docs/user-guide.md).
Expand Down Expand Up @@ -88,9 +88,9 @@ The following commands are available when you select a project in the Liberty Da
## Requirements

<!-- Match the VSCode and Java version on top of README.md, and user-guide.md -->
**Visual Studio Code 1.78.0** or later, and **Java 17** or later.
**Visual Studio Code 1.78.0** or later, and **Java 21** or later.

Liberty Tools for Visual Studio Code will check the `xml.java.home` VS Code setting or the `JAVA_HOME` system environment variable to ensure the LemMinX language server uses Java 17 or later. For further information on configuring your Java runtime for language servers, consult this [user guide section](/docs/user-guide.md#configure-your-java-runtime-for-language-servers).
Liberty Tools for Visual Studio Code will check the `xml.java.home` VS Code setting or the `JAVA_HOME` system environment variable to ensure the LemMinX language server uses Java 21 or later. For further information on configuring your Java runtime for language servers, consult this [user guide section](/docs/user-guide.md#configure-your-java-runtime-for-language-servers).

The following extensions are bundled with Liberty Tools for Visual Studio Code during installation and are provided here for additional information.

Expand Down
Binary file added docs/screenshots/java_21_toast_alert.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/screenshots/update jdk toast.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For information regarding known issues and limitations, refer to our [Common Iss
### Software requirements
<!-- Match the VSCode and Java version with the README.md -->
- **Visual Studio Code 1.78.0** or later.
- **Java 17** or later is required by Liberty Tools for Visual Studio Code. To point Visual Studio Code to a specific runtime, see [Settings](#settings) for more information.
- **Java 21** or later is required by Liberty Tools for Visual Studio Code. To point Visual Studio Code to a specific runtime, see [Settings](#settings) for more information.

### Application requirements

Expand All @@ -43,24 +43,24 @@ For information regarding known issues and limitations, refer to our [Common Iss

### Configure your Java runtime for language servers

Liberty Tools for Visual Studio Code requires Java 17 or later to ensure that the following language servers start properly:
Liberty Tools for Visual Studio Code requires Java 21 or later to ensure that the following language servers start properly:
- [Liberty Config Language Server](https://github.com/OpenLiberty/liberty-language-server)
- [Eclipse Language Server for Jakarta EE](https://github.com/eclipse/lsp4jakarta)
- [XML Language Server (LemMinX)](https://github.com/eclipse/lemminx)

A toast message alerts you if any language server fails to run or if Visual Studio Code has trouble locating your Java.

<img src="/docs/screenshots/update%20jdk%20toast.png" width="40%"/>
<img src="/docs/screenshots/java_17_toast_alert.png" width="40%" />
<img src="/docs/screenshots/java_21_toast_alert.png" width="40%" />

To resolve this issue, you can define settings in your Visual Studio Code [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson) file or set system environment variables to point Liberty Tools to Java 17 or later.
To resolve this issue, you can define settings in your Visual Studio Code [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settingsjson) file or set system environment variables to point Liberty Tools to Java 21 or later.

For both Liberty Config Language Server and Eclipse Language Server for Jakarta EE, Liberty Tools for Visual Studio Code will check for the Java versions in the following order:
1. `java.jdt.ls.java.home` in settings.json
2. The [embedded JRE](https://github.com/redhat-developer/vscode-java#java-tooling-jdk) included by [Language Support for Java(TM) by Red Hat](https://marketplace.visualstudio.com/items?itemName=redhat.java).
3. `JDK_HOME` or `JAVA_HOME` as system environment variables. (Note: if both `JDK_HOME` and `JAVA_HOME` are set, `JDK_HOME` will take precedence)

By default, Liberty Tools installs the latest version of the Language Support for Java(TM) by Red Hat extension. The latest version contains an embedded JRE higher than Java 17 and therefore no additional configuration is required. However, if using an older version of the Language Support for Java(TM) by Red Hat extension or using the universal version without the embedded JRE causes an issue, then `java.jdt.ls.java.home` or one of JDK_HOME or JAVA_HOME must be configured to use Java 17 or later.
By default, Liberty Tools installs the latest version of the Language Support for Java(TM) by Red Hat extension. The latest version contains an embedded JRE higher than Java 21 and therefore no additional configuration is required. However, if using an older version of the Language Support for Java(TM) by Red Hat extension or using the universal version without the embedded JRE causes an issue, then `java.jdt.ls.java.home` or one of JDK_HOME or JAVA_HOME must be configured to use Java 21 or later.

For LemMinX, Liberty Tools for Visual Studio Code will check for the Java versions in the following order:
1. `xml.java.home` in settings.json
Expand All @@ -76,7 +76,7 @@ For LemMinX, Liberty Tools for Visual Studio Code will check for the Java versio
| `maven.executable.preferMavenWrapper` | Maven commands executed by dev mode honour this setting. If this setting set to `true`, dev mode tries to use `mvnw` if a Maven wrapper file can be found. Otherwise, it uses `mvn`. | [Maven for Java extension](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven) |
| `java.import.gradle.wrapper.enabled` | Gradle commands executed by dev mode honour this setting. If this setting is set to `true`, dev mode tries to use `gradlew` if a Gradle wrapper file can be found. Otherwise, it uses `gradle`. | [Language support for Java extension](https://marketplace.visualstudio.com/items?itemName=redhat.java) |
| `xml.java.home` | This setting allows a user to define their LemMinX language server runtime without altering the `JAVA_HOME` environment variable. | Not set |
| `java.jdt.ls.java.home` | This setting specifies the folder path to the JDK (17 or later) that is used to launch the Java Language Server. This setting replaces the Java extension's embedded JRE to start the language servers. | Not set |
| `java.jdt.ls.java.home` | This setting specifies the folder path to the JDK (21 or later) that is used to launch the Java Language Server. This setting replaces the Java extension's embedded JRE to start the language servers. | Not set |

### Terminal shell support

Expand Down
4 changes: 2 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
"liberty.dev.attach.debugger.failed.with.error": "Failed to attach debugger to selected project. The error is: {0}.",
"liberty.dev.debug.label": "Debug {0}",
"liberty.dev.attach.debugger.failed.no.port.in.server.env": "Failed to detect remote debug port in {0}.",
"check.java.runtime.version.outdated": "Java 17 or later is required to run 'Liberty Tools for VS Code'. Download and install a recent Java SDK.",
"check.java.runtime.version.outdated": "Java {0} or later is required to run 'Liberty Tools for VS Code'. Download and install a recent Java SDK.",
"check.java.runtime.vscode.java.home": "The java.home variable defined in VS Code settings",
"check.java.runtime.env.jdk.home": "The JDK_HOME environment variable",
"check.java.runtime.env.java.home": "The JAVA_HOME environment variable",
"define.xml.java.home.message": "The Liberty Config Language Server requires Java 17 or later. Set 'xml.java.home' in the VS Code settings or set the system JAVA_HOME environment variable to point to a Java 17 or later SDK.",
"define.xml.java.home.message": "The Liberty Config Language Server requires Java {0} or later. Set 'xml.java.home' in the VS Code settings or set the system JAVA_HOME environment variable to point to a Java {0} or later SDK.",
"check.java.runtime.dismiss.label": "Dismiss",
"open.jdk.download.part.missing.folder": " points to a missing folder.",
"open.jdk.download.part.no.runtime": " does not point to a Java runtime.",
Expand Down
12 changes: 7 additions & 5 deletions src/util/requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { localize } from './i18nUtil';
const isWindows = process.platform.indexOf('win') === 0;
const JAVA_FILENAME = 'java' + (isWindows?'.exe': '');

const REQUIRED_JAVA_VERSION = 21;

export interface RequirementsData {
tooling_jre: string;
tooling_jre_version: number;
Expand All @@ -50,7 +52,7 @@ export async function resolveRequirements(api: JavaExtensionAPI): Promise<Requir
const requirementsData = api.javaRequirement;
// Java check for LSP4Jakarta and LCLS support
// Reuse the embedded JRE from 'redhat.java' if it exists and passes check
if (requirementsData && requirementsData.tooling_jre_version >= 17) {
if (requirementsData && requirementsData.tooling_jre_version >= REQUIRED_JAVA_VERSION) {
return Promise.resolve(requirementsData);
}

Expand Down Expand Up @@ -108,16 +110,16 @@ function readJavaHomeConfig(property: string): string|undefined {
return (javaHome != null) ? javaHome : config.get<string>('java.home');
}

// Provided javaHome, parse major version and reject sub Java17
// Provided javaHome, parse major version and reject sub Java21
function checkJavaVersion(javaHome: string, promptDownload: boolean): Promise<number> {
return new Promise((resolve, reject) => {
cp.execFile(javaHome + '/bin/java', ['-version'], {}, (error, stdout, stderr) => {
const javaVersion = parseMajorVersion(stderr);
if (javaVersion < 17) {
if (javaVersion < REQUIRED_JAVA_VERSION) {
if (promptDownload) {
openJDKDownload(reject, localize("check.java.runtime.version.outdated"));
openJDKDownload(reject, localize("check.java.runtime.version.outdated", REQUIRED_JAVA_VERSION));
} else {
defineXmlJavaHome(reject, localize("define.xml.java.home.message"));
defineXmlJavaHome(reject, localize("define.xml.java.home.message", REQUIRED_JAVA_VERSION));
}
} else {
resolve(javaVersion);
Expand Down
Loading