adam bien's blog

Java 16: a minimalistic Apache Maven / pom.xml 📎

To use Java 16 with Apache Maven, you will have to set the following properties:

<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<java.version>16</java.version>

With the following pom.xml:


<project>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.airhacks</groupId>
    <artifactId>java16</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
            </plugin>
        </plugins>
    </build>
    <dependencies>
	<dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.7.1</version>
            <scope>test</scope>
	</dependency>
    </dependencies>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>16</maven.compiler.source>
        <maven.compiler.target>16</maven.compiler.target>
        <java.version>16</java.version>
    </properties>
    
</project>    

you should be able to use e.g. text blocks:


public class Java16Test {
    @Test
    public void hello() {
        var message = """
            hello, java 16
                """;
        System.out.println(message);
    }
}