This page looks best with JavaScript enabled

Enable Java 14 preview features in Gradle, Maven and Idea

 ·  ☕ 2 min read

Discover how to enable Java 14 preview features in Gradle, Maven, Idea and Command line.

Bride undrawing a curtain

Writing my next post about the improved instanceof operator in Java 14, I have noticed that enabling the preview features might be a good candidate for a short blog post to reference in other places.

Let’s start with the basics.

Command line

Standalone files with preview features of Java 14 can be easily run from the command line (especially as calling javac is no longer needed):

java --source 14 --enable-preview


IntelliJ IDEA is known to support the new features and technologies in advance. With Java 14, it is available in Idea 2020.1, which the EAP (Early Access Program) version has been released in January 2020 .

It should be enough to just change the Java language settings in a given project to Java 14.


For Maven, just a few lines of XML should be required (I haven’t tested, I’m a Gradle guy ;-) :



For Gradle, version 6.3 (currently available as SNAPSHOT only ) is required for run with Java 14. To cover multiple compile and test tasks in the project the following construction could be used:

sourceCompatibility = 14

tasks.withType(JavaCompile) {
    options.compilerArgs += '--enable-preview'
tasks.withType(Test) {
    jvmArgs += "--enable-preview"


Nothing fancy in this post, but I feel in my bones that I will use it as a reference more than once during my Migration to modern Java training :-).

Lead photo by StockSnap, published in Pixabay, Pixabay License.
Share on

Marcin Zajączkowski
Marcin Zajączkowski
Software Craftsman & Software Architect
An experienced architect aiming for high quality solutions. Very engaged in evangelising Software Craftsmanship, Clean Code and Test-Driven Development as a conference speaker and a trainer. A specialist in Continuous Delivery and Continuous Inspection of Code Quality. An enthusiast of Reactive Systems and broadly defined concurrency.

Besides, open source author and contributor, a proud Linux user.

Don't want to use the Utterance bot? Comments can be also placed directly on GitHub.
What's on this Page