2

I have a java application coded in java 8, but we are using weblogic container that supports only java 1.6, can you please let me know if there is any way I can compile my source in Java 8 and force it to compatible with java 1.6 using maven as like source to 1.8 and target to 1.6?

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
Vignesh
  • 91
  • 7

2 Answers2

0

No, and this is a limitation of javac itself, it has nothing to do with maven.

There are some options for attempting to use j1.8 features and then compile it down to j1.6/j1.7 JVMs, see Can Java 8 code be compiled to run on Java 7 JVM?

However, note that JDK8 is about to end-of-life, and JDK6/7 are looong gone. You really should address that instead. Your container is at serious risk of having security issues (in that JDK6 and 7 no longer receive security patches).

rzwitserloot
  • 85,357
  • 5
  • 51
  • 72
0

You can run Java 6 applications on Java 8, BUT Java 8 features are not available on Java 6.

JVM says no. ;)

Mick
  • 954
  • 7
  • 17