Image for post
Image for post

Java still used for many digital product companies even today. Currently, Java is on version 13. Today I want to show how to use JDK13 with Gradle6. JDK13 has some improvements on GC(as usual), minor new methods for Strings and IO and there are 2 interesting new Experimental Features. So let’s get started.

Let’s take a look at the build.gradle file.

Besides using the Java plugin. We need to set the source code compatibility and target to 13. We also need to pass additional parameters for compile, testing and running in order to enable experimental features. Now we can go to the new Experimental features in Java 13.

Java 13 Code

So here we have 2 features. First, we have a multi-line string with “”” and then we can pass a Json object without annoying scaping “\” like we had to do it before. The other cool feature is that we can use switch statements directly in a variable which makes the switch more similar to a pattern matcher.

Here is the complete code on my GitHub.

Cheers,
Diego Pacheco

Originally published at http://diego-pacheco.blogspot.com on February 6, 2020.

Brazilian, Software Architect, SWE(Java, Scala, Rust, Go) SOA & DevOps expert, Author. Working with EKS/K8S. diegopacheco.github.io (Opinions on my own)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store