Launch maven using a different version of Java than the one used to start maven

I am using maven 3.2.5 to create my project, this version of maven is compatible with java 6.

I want to create a project that will use java 5 with the maven-enforcer plugin.

If I installed JAVA_HOME in the java 5 directory, I cannot start maven, and if I installed JAVA_HOME in the java 6 directory, the plugin forces a complaint about the java version.

Is there a way to tell maven to use a different version of java from the one used to start maven?

+4
source share
3 answers

, , . Maven JDK 7 (, Maven 3.5.0), JDK 6.

. toolchains.

+4

maven , javac, , :

   <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.6.1</version>
    <configuration>
      <verbose>true</verbose>
      <fork>true</fork>
      <executable>WRITE HERE THE PATH TO YOUR JAVAC 1.5</executable>
      <compilerVersion>1.5</compilerVersion>
    </configuration>
  </plugin>
+1

  • java-
  • ""
-1

Source: https://habr.com/ru/post/1679140/


All Articles