Saturday, January 28, 2012

Configure pom.xml to use JAVA_HOME to compile a mavan project

If you have a new maven project then you will definitely need to use another jdk version instead of maven default jdk version which is jdk_1.3 to build your maven project. Here I point you out how to use your JAVA_HOME to build your maven project. It is simple what you need is just add maven-compiler-plugin to pom.xml file of your project as i have mentioned below.

I have exported jdk_1.6.0_30 as my JAVA_HOME variable in .bashrc file and have set PATH bin.

i.e : export JAVA_HOME=/path/to/jdk
export PATH=$JAVA_HOME/bin:$PATH 

Here is how i uses my jdk_1.6 to build my maven project.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <executable>${java.home}/bin</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>

0 comments:

Post a Comment

Sample Text

Website counter

Categories