Skip to content

nipafx/demo-java-x

Repository files navigation

Java X Feature Demo

Demonstrates most features that were introduced after Java 8. They are listed below with links that take you to the demos in this repo, the JEPs responsible for introducing the feature, and to other sources if available. These are the categories:

Circled numbers like ⑰ indicate which Java version introduced a feature or a change. A circled X ⓧ indicates an incubating or previewing feature that is not yet standardized - it can be experimented with but is subject to change.

For a more practical approach to many of these features, including some quick code metrics, check my Java After Eight repo. You can find more from me on nipafx.dev as well as on YouTube and Twitch. To get in touch, follow me on Twitter (DMs are open) or join my Discord.

Setup

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 directly from jdk.java.net, although I prefer to use SDKMAN to install and manage them. The project can be built with Maven, i.e. mvn package.

There are several ways to execute demos:

  • If your IDE is up to speed (which may require preview versions or additional plugins), you can execute most demos straight from there.
  • If a feature is contained in a single class, you can also use single-source file execution and just call java $SOURCE_FILE.
  • You can always build with mvn package and then run any specific class with ...
     java -p target/java-x.jar -m dev.nipafx.demo.java_x/$CLASS
    ... where $CLASS is the fully qualified name of the class you want to execute.

Depending on the demo you may have to add additional command line flags - this should be listed in the respective file.

For some features, you have to run the .sh scripts in this repo's root directory to see them in action. If that's necessary, the feature list below mentions it. For that to work, you need to ensure that a java binary from the respective JDK version is available on your path - again, I use SDKMAN for that.

Language Changes

Module System

The module system is too big to demo here. Check out the j_ms tag on my blog (for example to find this handy cheat-sheet), the dedicated demo project, a project with solutions to common issues, or my book The Java Module System.

New APIs

If an API that was introduced in Java 9+ was later updated, the update is listed in the next section.

Updated APIs

A few changes have their own articles (in which case they are linked), but many don't. Some of them are show-cased in these posts, though:

Tooling

Runtime

Internals