I have my JAVA_HOME set to
C:\Program Files (x86)\Java\jdk1.6.0_18
After I run maven install I get this message from eclipse:
Reason:
Unable to locate the Javac Compiler in:
C:\Program Files (x86)\Java\jre6\..\lib\tools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
I'm certain that this is the tricky part
Please ensure you are using JDK 1.4 or above and not a JRE
When I run configuration its set to JRE6, how do I change it to JDK 1.6 which I have already installed
EDIT
I even tried to modify the plugin :
<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>C:\Program Files (x86)\Java\jdk1.6.0_18\bin</executable>
</configuration>
</plugin>
Still I get the same error
Maybe I forgot to say I use eclipse maven plugin .. how can I change from JRE to JDK in eclipse ?
Base on http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html, you will have to set the fork to true in your pom.xml.
Eclipse setup only
Do the following steps:
Right Click on Eclipse project Properties
Java Build Path -> Libraries
Select JRE System Library -> Click Edit button
Click "Installed JREs..." button
Edit JRE as: Set JRE Home = JAVA_HOME or JAVA_HOME\jre
ScreentShot:
Many Thanks,
Partha
I have just install maven 3.0.4, set
M2_HOME
,M2
andJAVA_HOME
accordingly. I then ran the following commands:mvn archetype:generate....
mvn compile
I got failed message such as:
maven unable to locate javac compiler
.On my computer, I have default jre install at c:\program files\java\jre.1.6. And I have the other c:\java\jdk1.6 and
JAVA_HOME
set to this c:\java\jdk1.6.I don't see anything wrong with my setting. After searching, I decided to look into
mvn.bat
, I echoed%JAVA_HOME%
every step and it displays correctly asC:\java\jdk1.6
but when I run the command :mvn --version
, it displays Java home: c:\program files\java\jre1.1.6.Finally, I found out that I just need to set
-Djava.home=c:\java\jdk1.6
as in the command below, and working fine now:%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Djava.home=%JAVA_HOME%" "-Dmaven.home=%M2_HOME%" %CLASSWORLDS_LAUNCHER% %MAVEN_CMD_LINE_ARGS%
Hope this helps.
Note: This is for
mvn
on command line and not with Eclipse.I changed the configuration of maven-compiler-plugin to add executable and fork with value true.
It worked for me.
You try:
Go to
Preferences/Java/Installed JREs
and add one for the location"C:\Program Files\Java\jdk1.6.0_27\jre
or something like that.Remove the one for
C:\Program Files\Java\jre6
As you can see, the path
C:\Program Files\Java\jre6\..\lib\tools.jar
only makes sense if the first part (til the /..) is replaced byC:\Program Files\Java\jdk1.6.0_27\jre
.I got the same problem using Run as -> Maven install in Eclipse. JAVA_HOME and eclipse.ini were OK and pointing to my latest JDK. But m2clipse used JRE. Using mvn install outside of Eclipse worked fine! In my case I solved the problem as follows: 1. Navigate in Eclipse: Window -> Preferences -> Java -> Installed JREs 2. There were two inactive entries for a JRE and JDK. The active one was the latest installed JDK. Delete all entries but the one maven should use.
I think maven doesn't take into acount which one is active...