How Maven knows where to find Java 1.5

In pom.xmlyou can:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.5</source>
                <target>1.5</target>
            </configuration>
        </plugin>
    </plugins>
</build>

How does Maven know where I have version 1.5?

+3
source share
3 answers

As far as I know, this will not compile Maven against Java 1.5 libraries. This will only tell the compiler to accept the 1.5-level source code and produce the 1.5-level class files.

Perhaps your code might reference Java 6 classes if your Maven task is running with the Java 6 JVM.

IF you are doing:

mvn -v

As a result, you will see which version of Java is used. For example:

Apache Maven 2.1.0 (r755702; 2009-03-18 19:10:27+0000)
Java version: 1.6.0_13
Java home: C:\Program Files\Java\jdk1.6.0_13\jre
Default locale: en_IE, platform encoding: Cp1252
OS name: "windows vista" version: "6.0" arch: "x86" Family: "windows"
+12
source

, Maven . JAVA_HOME. Windows echo% JAVA_HOME% Linux echo $JAVA_HOME .

, , Maven.

+1

I knew that maven figured out where to find my JDK without me by setting $ JAVA_HOME. After uninstalling the default JDK, Maven was still looking at its original location and throwing an error.

I did not want to install $ JAVA_HOME if the mechanism was already installed. In the end, I found ~ / .mavenrc that contained the JAVA_HOME setting.

I fixed it, and presto, everything was happy.

0
source

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


All Articles