We are moved to new domain
Click -> www.ehowtonow.com
Wednesday, 16 August 2017

Configure Maven to use Java 8 for Compile the code

In pom.xml we can configure maven.compiler.source maven.compiler.target properties to tell Maven to use Java 8 (or particular Java version ) to compile the project.

Setting the -source and -target of the Java Compiler 

Sometimes when you may need to compile a certain project to a different version than what you are currently using. The javac can accept such command using -source and -target.

We can configure Java Version using Maven properties. Sample Maven properties for Java 7 and Java 8 given below.


Maven Properties 

Java 7 pom.xml

    1.7
    1.7

Java 8 pom.xml

    1.8
    1.8

Alternatively we can configure Java Version using Maven Compiler plugin.

Maven Compiler Plugin

pom.xml

    
        
            org.apache.maven.plugins
            maven-compiler-plugin
            3.6.1
            
                1.8
                1.8
            
        
    

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: Configure Maven to use Java 8 for Compile the code Rating: 5 Reviewed By: eHowToNow