I\'m trying to use maven to build a jar but I keep getting the error
ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(d
If anybody has Eclipse Kepler SR2 and has an issue with Java 1.8 while building project with Maven, try to go to Eclipse Marketplace and search for plugin called Java 8 support for m2e for Eclipse Kepler SR2 this helped me, and now Maven compiles Java 1.8 source without problem.
Maven relies on the JAVA_HOME environment variable being set. Set it according to your OS and re-run your build.
Edit: Use export to set the variable.
export JAVA_HOME=/path/to/java
you can try configuration in compiler plugin. Its working on my local
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<executable><!--path-to-your-java8-home-directoru--></executable>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
As a MacOS user, open a Terminal
and create or edit a file .bash_profile
(in the directory of your user home) and put the following snippet there:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Save that file and reopen a Terminal instance. If you execute export
as a command there, you should see a valid JAVA_HOME
with the location of your JDK 8 installation. Restart your IDE afterwards and maven should be able to build you nice java target 1.8
code.
Yes it seems a bug in the maven-compiler-plugin.When I upgraded from 3.1 to 3.5.1, it works.
I'm not sure but can you try to update your maven.plugin version
try
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<version>3.6.1</version>
</plugin>