Java After Eight Feature Demo
Demonstrates the features of Java 9, 10, and 11. The links below take you to the demos in this project, the JEPs responsible for introducing the feature, and to other sources if available.
These articles discuss the recent Java versions and list a lot of the new features:
- Code-First Java 9 Tutorial
- The Ultimate Guide to Java 9
- Inside Java 9 – Version Schema, Multi-Release JARs, and More
- Inside Java 9 – Performance, Compiler, and More
This project requires at least the most recent Java release, at times even early-access builds of upcoming versions. You can get OpenJDK builds for both from jdk.java.net.
Most of the project can be built with Maven.
It uses toolchains to configure which Java version Maven should use for compilation and packaging.
toolchains.xml in Maven's user folder (
~/.m2 on Linux) to contain a block like the following:
<!-- if the file already contains a <toolchains> tag, you only need the inner <toolchain> block --> <toolchains> <toolchain> <type>jdk</type> <provides> <version>12</version> <vendor>OpenJDK</vendor> </provides> <configuration> <jdkHome>/opt/jdk-12</jdkHome> </configuration> </toolchain> </toolchains>
If your IDE doesn't like new syntax or APIs, you can always compile and run by hand - see
run.sh (which expects the fully qualified name of the main class as argument) and
compile-run.sh (conveniently combines the two - aso needs the main class).
The scripts are written for Linux but should look similar on other operating systems.
If the approprate Java verson is not on your path, configure it in
For some features, you have to run the
.sh scripts in the root directory.
If that's necessary, the feature list below mentions it.
Java Platform Module System
- ⑫ switch expressions (article, video, JEP 325)
- ⑩ local-variable type inference with
var(article, video, JEP 286)
- ⑨ private interface methods (JEP 213)
- ⑨ try-with-resources on effectively final variables (JEP 213)
- ⑨ diamond operator for anonymous classes (JEP 213)
@SaveVarargson private non-final methods (JEP 213)
- ⑨ no warnings for deprecated imports (JEP 211)
- ⑪ HTTP/2 client: simple, more formal (tutorial, reactive request/response bodies)
- ⑨⑩ version API, introduced in Java 9, updated in Java 10
- ⑨ collection factory methods (instead of collection literals; JEP 269)
- ⑨ reactive streams (JEP 266)
- ⑨ stack walking (JEP 259, post on SitePoint including benchmarks)
- ⑨ multi-resolution images (JEP 251)
- ⑨ platform-specific desktop features (not supported by my OS so my sample sucks; PRs welcome! JEP 272)
- ⑨ deserialization filter (targeted for JDK 9 but wasn't implemented when I created this; JEP 290)
- ⑪ I/O (article)
Optionalin Java 9 (article) and Java 11 (article)
- ⑨ OS processes (JEP 102)
JVM & Tooling
- ⑪ single-source-file execution and scripting: run the script with
cat echo-haiku.txt | ./echo(article, JEP 330)
- ⑩ application class-dara sharing (article, JEP 310)
- ⑨ multi-release JARs: classes and the script (JEP 238)
- ⑨ platform logging: classes and the script (JEP 264)