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 ?
eclipse.ini needs the vm argument to point to your jdk location.
Edit the
eclipse.ini
file to point to your jdk home, something as follows -This ensures that Eclipse would be running off the JDK and not any default JRE on your machine.
If you set the JAVA_HOME, and the problem persists try the following. (i had the same problem, on a fresh installed pc.)
Assuming you are using Eclipse.
Thats all. your project will not suffer from sutch problems. Hope helps.
As mentioned by several others, the Eclipse
Window->Preferences...->Java->Installed JREs
should point to the JDK you installed, not to the JRE. Only then it can find the../lib
folder mentioned in the error message.Even with this, the problem may recur. My way out in Eclipse (Juno) is to do a
Maven -> Update project...
after which the problem disappears.I suspect the reason is that some of the Eclipse generated files (.classpath, .project, .preferences) are in subversion for the project in which I'm having these problems. Thus, an svn update introduces the problem, and an configuration update from maven in Eclipse resolves it again.
Real solution: omit Eclipse generated .files from version control, and let the maven eclipse plugin handle project configuration. (additional pointers/suggestions welcome).
I had EXACT the same problem! Been searching and searching for days because all the babble about "put the -vm c:\program files\java\jdkxxxxx\bin" in the ini ar as argument for a shortcurt did NOT AT ALL heklp! (Do I sound frustrated? Believe me, that's an understatement! I am simply furious because I lost a week trying to make Maven reliable!)
I had very unpredictable behavior. Sometimes it compiled, sometimes not. If I did a maven clean, it could not find the compiler and failed. If I then changed something in the build path, it suddenly worked again!!
Until I went to window -> preferences -> java -> installed JRE's. I added a new JRE using the location of the JDK and then removed the JRE. Suddenly maven ran stable!
Maybe this is worth putting in letters with font-size 30 or so in the apache manual? With all due respect, this is simply outrageous for the java community! I can't imagine how many days were lost by all these people, trying to work out their problems of this kind! I cannot possibly imagine this is released as a final version. I personally would not even dare to release such a thing under the name BETA software...
Kind regards either way.... After a week of tampering I can finally start developing. I hope my boss won't find out about this. It took me lots of effort to convince him NOT to go to .NET and I already feel sorry about it.
Make sure the "-vm" in your eclipse.ini is on two sperate lines, ie:
In my case, in eclipse
Run-> Debug Configurations
In the jre tab selected the jdk instead of the jre solved the problem.