Skip to content

Commit

Permalink
Require Java 11
Browse files Browse the repository at this point in the history
lemminx is moving to Java 11,
so this PR ensures that a Java 11 JRE/JDK is used to run lemminx
(or uses the binary if Java 11 is not installed).

This PR also updates the documentation to reflect the new Java 11
requirement.

It also updates the documentation related to instructions on setting up
GraalVM for locally building the binary.

Signed-off-by: David Thompson <davthomp@redhat.com>
  • Loading branch information
datho7561 committed Jan 10, 2025
1 parent f666928 commit 53f04ba
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Contributions are essential for keeping this extension great. We try to keep it

* latest [Visual Studio Code](https://code.visualstudio.com/)
* [Node.js](https://nodejs.org/) v4.0.0 or higher
* [JDK 8+](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [JDK 11+](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
* [Maven](https://maven.apache.org/)

### Steps
Expand Down Expand Up @@ -118,8 +118,7 @@ If you submit a LemMinX PR, GitHub Actions will generate a binary for your PR th
If you need to generate a LemMinX binary locally for whatever reason, follow these steps:

1. Download and set up [GraalVM and its dependencies](https://www.graalvm.org/docs/getting-started/)
* either 20.x or 21.x should work
* The version for Java 11 is preferred, since it is hard to set up GraalVM Java 8 on Windows
* The latest version should work
2. Make sure that the environment variable `JAVA_HOME` points to the GraalVM installation.
3. Run `./mvnw clean package -DskipTests -Dnative` from the root of the LemMinX repository
* This will use a lot of memory (> 4 GB) and take a while
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,18 @@ or you can read this documentation inside vscode with the command `Open XML Docu

For running the binary version:
* Windows, macOS, or Linux, on a x86_64 CPU
* We do not currently support running on Linux installations without `libc` present
* ~~We do not currently support running on Linux installations without `libc` present~~ See [#1016](https://github.com/redhat-developer/vscode-xml/pull/1016)
* Java is not required for this version
* The binary is automatically downloaded by vscode-xml if it is needed, with no additional action required on the part of the user.

For running the Java version (required if you want to run [extensions](./docs/Extensions.md#custom-xml-extensions) to the base XML features):
* Java JDK (or JRE) 8 or more recent
* Java JDK (or JRE) 11 or more recent
* Ensure Java path is set in either:
* `xml.java.home` in VSCode preferences
* `java.home` in VSCode preferences
* Environment variable `JAVA_HOME` or `JDK_HOME`
* **Note**: The path should end at the parent folder that contains the `bin` folder.
**Example Path**: `/usr/lib/jvm/java-1.8.0` if `bin` exists at `/usr/lib/jvm/java-1.8.0/bin`.
**Example Path**: `/usr/lib/jvm/jre-11` if `bin` exists at `/usr/lib/jvm/jre-11/bin`.
* **Note**: If the path is not set, the extension will attempt to find the path to the JDK or JRE.

See [how to set java home](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Preferences.md#java-home) for more information how this extension searches for Java.
Expand All @@ -78,7 +78,7 @@ See [how to set java home](https://github.com/redhat-developer/vscode-xml/blob/m

The following settings are supported:

* [`xml.java.home`](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Preferences.md#java-home): Specifies the folder path to the JDK (8 or more recent) used to launch the XML Language Server if the Java server is being run. If not set, falls back to either the `java.home` preference or the `JAVA_HOME` or `JDK_HOME` environment variables.
* [`xml.java.home`](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Preferences.md#java-home): Specifies the folder path to the JDK (11 or more recent) used to launch the XML Language Server if the Java server is being run. If not set, falls back to either the `java.home` preference or the `JAVA_HOME` or `JDK_HOME` environment variables.
* [`xml.server.vmargs`](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Preferences.md#server-vm-arguments): Specifies extra VM arguments used to launch the XML Language Server.
Eg. use `-Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication` to bypass class verification, increase the heap size to 1GB and enable String deduplication with the G1 Garbage collector.
* [`xml.server.workDir`](https://github.com/redhat-developer/vscode-xml/blob/main/docs/Preferences.md#server-cache-path): Set a custom folder path for cached XML Schemas. An absolute path is expected, although the `~` prefix (for the user home directory) is supported. Default is `~/.lemminx`.
Expand Down
2 changes: 1 addition & 1 deletion docs/Preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* An environment variable `JAVA_HOME` or `JDK_HOME`

Please note:
* The path should end at the parent folder that contains the bin folder. As an example, use `/usr/lib/jvm/java-1.8.0` if the bin folder exists at `/usr/lib/jvm/java-1.8.0/bin`.
* The path should end at the parent folder that contains the bin folder. As an example, use `/usr/lib/jvm/jre-11` if the bin folder exists at `/usr/lib/jvm/jre-11/bin`.
* If the path is not set, the extension will attempt to find the path to the JDK or JRE.

## Server VM Arguments
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-xml",
"displayName": "XML",
"description": "XML Language Support by Red Hat",
"version": "0.27.3",
"version": "0.28.0",
"author": "Red Hat",
"publisher": "redhat",
"icon": "icons/icon128.png",
Expand Down Expand Up @@ -160,7 +160,7 @@
"null"
],
"default": null,
"markdownDescription": "Specifies the folder path to the JDK (8 or more recent) used to launch the XML Language Server if the Java server is being run.\nOn Windows, backslashes must be escaped, i.e.\n`\"xml.java.home\": \"C:\\\\Program Files\\\\Java\\\\jdk1.8.0_161\"`. For more information, please refer to [this document](command:xml.open.docs?%5B%7B%22page%22%3A%22Preferences%22%2C%22section%22%3A%22java-home%22%7D%5D).",
"markdownDescription": "Specifies the folder path to the JDK (11 or more recent) used to launch the XML Language Server if the Java server is being run.\nOn Windows, backslashes must be escaped, i.e.\n`\"xml.java.home\": \"C:\\\\Program Files\\\\Java\\\\jdk11\"`. For more information, please refer to [this document](command:xml.open.docs?%5B%7B%22page%22%3A%22Preferences%22%2C%22section%22%3A%22java-home%22%7D%5D).",
"scope": "window"
},
"xml.server.vmargs": {
Expand Down
5 changes: 3 additions & 2 deletions src/server/requirements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ function sortJdksBySource(jdks: IJavaRuntime[]) {
}
}
rankedJdks.filter(jdk => jdk.rank === undefined).forEach(jdk => jdk.rank = sources.length);
rankedJdks.filter(jdk => jdk.version.major >= 11);
rankedJdks.sort((a, b) => a.rank - b.rank);
}

Expand All @@ -151,8 +152,8 @@ function checkJavaVersion(java_home: string): Promise<number> {
return new Promise((resolve, reject) => {
cp.execFile(java_home + '/bin/java', ['-version'], {}, (error, stdout, stderr) => {
const javaVersion = parseMajorVersion(stderr);
if (javaVersion < 8) {
reject(openJDKDownload('Java 8 or more recent is required to run. Please download and install a recent Java runtime.'));
if (javaVersion < 11) {
reject(openJDKDownload('Java 11 or more recent is required to run. Please download and install a recent Java runtime.'));
}
else {
resolve(javaVersion);
Expand Down
2 changes: 1 addition & 1 deletion src/server/serverStarter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function prepareExecutable(
const CONFIGURE_JAVA = 'More Info';
const DISABLE_WARNING = 'Disable Warning';
window.showInformationMessage('Extensions to the XML language server were detected, but no Java was found. '
+ 'In order to use these extensions, please install and configure a Java runtime (Java 8 or more recent).',
+ 'In order to use these extensions, please install and configure a Java runtime (Java 11 or more recent).',
DOWNLOAD_JAVA, CONFIGURE_JAVA, DISABLE_WARNING)
.then((selection: string) => {
if (selection === DOWNLOAD_JAVA) {
Expand Down

0 comments on commit 53f04ba

Please sign in to comment.