I\'m compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this:
Windows-->preferences-->installed jres--> jdk1.7.xx p
I got same issue and i just add JAVA_HOME
to environment variables.
JAVA_HOME
open command prompt from project directory and run mvn clean install
(don't use intellij terminal).I did the following change and it worked for me.Hope it helps someone.
Try this.
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable> path to jdk \bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>
In Windows 7 - 64 bit, there is a permissions problem which prevents the installer from unpacking the file C:\Program Files\Java\jdk1.6.xx\lib\tools.jar into your local. This jar file is what maven-compiler-plugin version 3.x uses instead of the usual javac
Solution: Run, as an administrator, the Java JDK installer! And make sure the tools.jar is sitting in the C:\Program Files\Java\jdk1.6.xx\lib\
In case you are using m2e maven integration plugin, you want to see the file is visible to Eclipse via the following steps inside Eclipse:
Go to Window -> Preferences -> Java -> installed JREs Select the JDK you are using (C:\Program Files\Java\jdk1.6.xx) Press Edit to see the list of jars including tools.jar, OR you can add it as Add External JAR Then configure the maven run through these steps:
Run->Run configurations->Fill in Name, Base directory and Goals. Then in the same window move to the JRE tab and point to the JDK \jdk1.6.xx\
Additionally, you may have to change Maven JRE (see @jlars62 answer) which is as follows. Goto Run -> Run Configurations, selecting the Maven Build I was running (from the left panel). Then, I clicked the JRE tab and selected the option Workspace default JRE
For me the JRE was in the PATH environment variable before the JDK path
So I removed 1. Probably swapping them would fix it too.