views:

319

answers:

2

In pom.xml you 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 1.5 version?

+1  A: 

I take it that we are talking about Maven here. I would guess via the JAVA_HOME environmental variable. If Windows do a echo %JAVA_HOME% or Linux do a echo $JAVA_HOME and see.

Oops: Sorry I see it is Maven.

uriDium
+9  A: 

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

Your code could still possibly refer to Java 6 classes, as long as your Maven task is run with a Java 6 JVM.

IF you execute:

mvn -v

The output will show you what version of Java is being 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"
Joachim Sauer