Configure Maven to use different JDK for different J2SE versions?

we solved this problem by explicitely sepecify the javac in config of compile plugin (with JAVA_HOME_6 and JAVA_HOME_7 defined as environment variables):

and for Java 6 module

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <executable>${env.JAVA_HOME_6}/bin/javac</executable>
        <fork>true</fork>
    </configuration>
</plugin>

and for Java 7 module

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <showDeprecation>true</showDeprecation>
        <showWarnings>true</showWarnings>
        <executable>${env.JAVA_HOME_7}/bin/javac</executable>
        <fork>true</fork>
    </configuration>
</plugin>

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)