The –release Option in Java 9 Compiler: What You Need to Know

06 May 2023 Balmiki Mandal 0 Core Java

What Is the -release Option in the Java 9 Compiler?

Java 9 has introduced a new flag for its compiler called the -release option. The -release option enables developers to compile code that targets either Java 8 or Java 9, depending on which version is desired for their application. This feature allows developers to maintain compatibility with older versions of Java while taking advantage of the new features of Java 9.

When compiling with the -release option, developers must specify the desired version of Java they want to target. The targeted version can either be a major version such as 8 or 9, or a specific update level such as 8u121 or 9.0.4. When using this option, the Java compiler will then use that specific release version as the baseline when compiling the code.

Using the -release option helps developers ensure that their code remains compatible with existing applications and libraries, while also being able to take advantage of the latest performance improvements and features included in Java 9. By not locking themselves into a specific version of the Java platform, developers have the ability to leverage new capabilities when they become available.

The -release option is available in both the javac command line tool and the IDEs that ship with Java. It should also be noted that developers who are using Maven or Gradle for builds must make sure to also set the appropriate targetCompatibility option, otherwise the build tools may default to an older version of Java.

BY: Balmiki Mandal

Related Blogs

Post Comments.

Login to Post a Comment

No comments yet, Be the first to comment.