Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to compile project on java 8 for target java 6?

I'm trying to build a project on java 8, specifying java 6 as the target:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
</build>

Project settings:

enter image description here

General IDE (Java compiler) settings:

enter image description here

And I wind up with the error:

javacTask: source release 1.8 requires target release 1.8

Is it possible at all to build a project on java 8 with java 6 as the target?

like image 737
Ksenia Avatar asked Sep 19 '25 19:09

Ksenia


1 Answers

You can develop in Java 8 and target JDK 6, but it requires a bit of tweaking.

If you use a plugin like Retrolambda, combined with backported libraries such as StreamSupport and ThreeTen, you can use newer features on older JDKs.

Just make sure to use Animal Sniffer to ensure you're not using newer Java API methods or classes.

like image 196
Jeroen Steenbeeke Avatar answered Sep 22 '25 09:09

Jeroen Steenbeeke