ERROR - javac: invalid target release: 1.8 Usage: javac use -help for a list of possible options while building project using Maven

Error

Failure executing javac, but could not parse the error:
javac: invalid target release: 1.8
Usage: javac <options> <source files>

use -help for a list of possible options

while building project using Maven.

Error Type


Build Time


Cause

Maven is looking for Java 8 to build the project but it's not able to figure where it's installed.

Very likely your JAVA_HOME is pointing to some other Java Directory ( and not Java 8 )

Resolution

Check the Directory configured within JAVA_HOME by using command 

echo $JAVA_HOME

and make sure that its the path for Java 8 directory

If not,

Following this to update your JAVA_HOME - http://stackoverflow.com/questions/24641536/how-to-set-java-home-in-linux-for-all-users

If you would like downgrade to some previous Java version which has been correctly set up within JAVA_HOME, add the following entries within your pom file 

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>

</plugin>

This will inform Maven that we would like to build the project with Java 6 and hence it will pick Java 6 from the directory configured within JAVA_HOME.