Skip to content

Instantly share code, notes, and snippets.

@RajaniCode
Last active March 17, 2024 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RajaniCode/7200dc9592e2b831a6a362721a496657 to your computer and use it in GitHub Desktop.
Save RajaniCode/7200dc9592e2b831a6a362721a496657 to your computer and use it in GitHub Desktop.
Java22.java
// Java 22
// OpenJDK 22
// % export PATH="/Users/rajaniapple/Downloads/Software/OpenJDK/JDK22/jdk-22.jdk/Contents/Home/bin/":$PATH
// % java --enable-preview --source 22 --enable-native-access=ALL-UNNAMED --add-modules=jdk.incubator.vector Java22.java
// Or
// % javac -Xlint:preview --enable-preview --source 22 --add-modules=jdk.incubator.vector Java22.java
// % java --enable-preview --enable-native-access=ALL-UNNAMED --add-modules=jdk.incubator.vector Java22
// Java 21
// OpenJDK 21
// % export PATH="/Users/rajaniapple/Downloads/Software/OpenJDK/JDK21/jdk-21.jdk/Contents/Home/bin/":$PATH
/*
# 1 # 423: Region Pinning for G1
# 2 # 447: Statements before super(...) (Preview)
# 3 # 454: Foreign Function & Memory API
# 4 # 456: Unnamed Variables & Patterns
# 5 # 457: Class-File API (Preview)
# 6 # 458: Launch Multi-File Source-Code Programs
# 7 # 459: String Templates (Second Preview)
# 8 # 460: Vector API (Seventh Incubator)
# 9 # 461: Stream Gatherers (Preview)
# 10 # 462: Structured Concurrency (Second Preview)
# 11 # 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)
# 12 # 464: Scoped Values (Second Preview)
*/
// import static java.lang.System.out;
// import java.lang.System;
class Java22 {
public static void main(String[] args) {
// public static void main(String... args) {
var propertiesSystem = new SystemProperties();
propertiesSystem.print();
// # 1 # 423: Region Pinning for G1
// # 2 # 447: Statements before super(...) (Preview)
// # 3 # 454: Foreign Function & Memory API
// # 4 # 456: Unnamed Variables & Patterns
// # 5 # 457: Class-File API (Preview)
// # 6 # 458: Launch Multi-File Source-Code Programs
// # 7 # 459: String Templates (Second Preview)
// # 8 # 460: Vector API (Seventh Incubator)
// # 9 # 461: Stream Gatherers (Preview)
// # 10 # 462: Structured Concurrency (Second Preview)
// # 11 # 463: Implicitly Declared Classes and Instance Main Methods (Second Preview)
// # 12 # 464: Scoped Values (Second Preview)
}
}
class SystemProperties {
public void print() {
System.out.println(String.format("OS Name: %s", System.getProperty("os.name")));
System.out.println(String.format("OS Version: %s", System.getProperty("os.version")));
System.out.println(String.format("OS Architecture: %s", System.getProperty("os.arch")));
System.out.println(String.format("Java Version: %s", System.getProperty("java.version")));
// System.getProperties().list(System.out);
System.out.println();
}
}
// Output
/*
WARNING: Using incubator modules: jdk.incubator.vector
OS Name: Mac OS X
OS Version: 14.0
OS Architecture: aarch64
Java Version: 22
*/
/*
Courtesies:
https://openjdk.java.net
https://docs.oracle.com
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment