Skip to content

Commit 673da56

Browse files
Java 21 for OH5 development (#2426)
* Java 21 for OH5 development Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> * rework after OH5 release Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> * review comment Signed-off-by: Holger Friedrich <mail@holger-friedrich.de> --------- Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
1 parent 82a24a4 commit 673da56

File tree

8 files changed

+16
-15
lines changed

8 files changed

+16
-15
lines changed

configuration/blockly/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Important: For Blockly to work, you need to have the [Javascript Scripting Addon
4444
### openHAB 3 / openHAB 4 to openHAB 4.3 or Later - Migration
4545

4646
From openHAB 4 onwards, the script engine is GraalJS provided by the [JS Scripting Addon](https://www.openhab.org/addons/automation/jsscripting/), **ECMAScript 2022**, when Blockly creates new scripts.
47-
OpenHAB versions before 4.3 could use **ECMAScript 2022** or **NashornJS** with **ECMAScript 5.1**, either installed by default or installed through an Addon.
47+
openHAB versions before 4.3 could use **ECMAScript 2022** or **NashornJS** with **ECMAScript 5.1**, either installed by default or installed through an Addon.
4848
**NashornJS** is no longer an option with openHAB 4.3 or later. Therefore the generated Blockly code needs to be converted to **ECMAScript 2022**.
4949

5050
Converting is as easy as making sure the [JS Scripting Addon](https://www.openhab.org/addons/automation/jsscripting/) is installed, and opening your Blockly script.

configuration/migration/index.md

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ You should probably do your usual OS backup too to make sure you can get back to
4646

4747
openHAB (since version 4) requires Java 17. Most modern Linux OS have an `openjdk-17-jdk` package available for you to install but alternative solutions such as [Zulu's OpenJDK](https://www.azul.com/downloads/zulu-community/?version=java-17-lts&package=jdk) (which openHABian can install for you) are available and these may run faster on 32-bit armhf platforms such as the Raspberry Pi.
4848

49+
openHAB 5 development requires Java 21.
50+
4951
You must also be on the relevant repository for openHAB, this hasn't changed for openHAB 4.x so the [same instructions for moving to it](https://www.openhab.org/docs/installation/linux.html#package-repository-installation) are still valid.
5052

5153
For DEB based installers (apt), your `.list` file should contain the line:

developers/ide/eclipse.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ If you already have Eclipse installed it is recommended to perform a separate Ec
1515

1616
## Eclipse IDE Setup
1717

18-
1. Install the Java 17 JDK if you did not have it installed.
18+
1. Install the Java 21 JDK if you did not have it installed.
1919

2020
::: warning Attention
21-
openHAB development requires **Java JDK version 17**.
21+
openHAB development requires **Java JDK version 21**.
2222
:::
2323

2424
1. Download the "Eclipse Installer": [can be downloaded from the Eclipse web site](https://wiki.eclipse.org/Eclipse_Installer)

developers/index.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Try [git - the simple guide](https://rogerdudler.github.io/git-guide/) as a star
1616
Add-ons and the openHAB core itself are written in Java.
1717
Java is not hard to learn, but it helps if you have a general technical understanding of programming languages.
1818

19-
The different guides of this chapter assume that you are somewhat familiar with Java 17 and that you have a rough understanding of Git's workflow (e.g. "checkout", "branches", "push").
19+
The different guides of this chapter assume that you are somewhat familiar with Java 21 and that you have a rough understanding of Git's workflow (e.g. "checkout", "branches", "push").
2020

2121
## Choose the Right Concept
2222

@@ -49,13 +49,10 @@ Please ensure that you have the following prerequisites installed as well:
4949

5050
1. [Git](https://git-scm.com/downloads) For retrieving our source code and push changes back. On Windows: Must be available in %PATH%
5151
1. [Maven 3.x](https://maven.apache.org/download.cgi) Our build system tool. On Windows: Must be available in %PATH%
52-
1. Java JDK 17 or JDK 21, for example from Oracle [Oracle JDK 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) or [Oracle JDK 21](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html). On Windows: %JAVA% must be set.
52+
1. Java JDK 21, for example from Oracle [Oracle JDK 21](https://www.oracle.com/java/technologies/javase/jdk21-archive-downloads.html). On Windows: %JAVA% must be set.
5353

5454
::: tip Note
55-
Whereas we recommend Java 17 for running openHAB, development can be safely done on Java 21.
56-
With default settings, the Java 21 compiler will generate Java objects compatible with JRE 17.
57-
If you run your openHAB server on Java 21, you can enable native Java 21 objects by adding `-Pj21` to the Maven command line.
58-
Note that our CI checks Java 17 and Java 21 compatibility, and we only use language features available in Java 17.
55+
Whereas openHAB 4.x series was based on Java 17, starting with openHAB 5.0.0-SNAPSHOT, **Java 21 is required**.
5956
:::
6057

6158
You can use any IDE that is suitable for OSGi/Java development.

installation/index.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ You could also [download Azul Zulu](https://www.azul.com/downloads/zulu-communit
4141
Oracle Java is also suitable for most configurations but it's not recommended. Licensing restrictions may apply.
4242

4343
::: warning
44-
Java 17 is recommended for openHAB.
45-
Using Java 21 is possible, but still considered experimental.
46-
OpenHABian can install Java 21, but only on the native 64-bit image.
44+
Java 17 is recommended for openHAB 4.x series.
45+
openHABian can install Java 21, but only on the native 64-bit image.
4746
Please note that versions of Java other than 17 and 21 are not supported at the moment.
47+
48+
openHAB 5 requires Java 21.
4849
:::
4950

5051
| Java Platform | Advantages | Disadvantages |

installation/linux.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ When installing Zulu or Zulu Embedded from a .zip or .tar archive, make sure to
3434

3535
::: tip Note
3636
Make sure to download Zulu or Java **17**.
37-
Using Java 21 is possible, but still considered experimental.
37+
Java 21 can be used openHAB 4.x, and is required for openHAB 5.
3838
:::
3939

4040
## Installation

installation/synology.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ title: Synology DiskStation
55

66
:::tip Note
77

8-
openHAB 4 and higher need Java 17.
8+
openHAB 4.x series requires Java 17.
9+
Java 21 can be used openHAB 4.x, and is required for openHAB 5.
910
You will need to provide a working Java installation on your DiskStation.
1011
The sections below are written for Java 11 but the docs are not updated currently, since we have not secured knowledge about how to install Java 17 on the DiskStation.
1112
If you can provide some proper sources and explanation, we are happy to include your contribution into this article.

installation/windows.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Please be sure you have installed the required supporting applications as descri
1919

2020
### Set the `JAVA_HOME` System Environment Variable in Windows
2121

22-
Note: If you have installed Zulu Java 17 (highly recommended for OH 4.x) you may skip this step because the JAVA_HOME environment variable was created during installation.
22+
Note: If you have installed Java 17 (recommended for OH 4.x) or Java 21, you may skip this step because the JAVA_HOME environment variable was created during installation.
2323

2424
- Navigate to: Control Panel ➡️ System and Security ➡️ System ➡️ Advanced System Settings ➡️ Environment Variables ➡️ System Variables
2525
- Create a New System Variable named JAVA_HOME (or update the existing one) to match the installation directory of the Java Platform chosen and installed in the step [Prerequisites]({{base}}/installation/index.html#prerequisites).

0 commit comments

Comments
 (0)