i created a webapp project using maven in eclipse. when i run the command mvn package in command prompt it showing folowing error.
[ERROR] COMPILATION ERROR
to set path in below manner
keep jdk's path at first place in path variable, so that other java path will be ignored. compilation error will be resolved.
After creating a second workspace to work in a separate source code branch, I ran into a bizarre situation where I could do a Maven build from the command line in the new workspace, but not in Eclipse. I tried setting the JRE configuration to the JDK as described by others, but still no luck. I finally had to search the entire contents of the new workspace's .metadata directory to find the offending files that refused to be reconfigured. The main culprit was
.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs
It still pointed to the wrong directory despite my configuration change. I did a manual edit to supply the correct JDK name and location. I also edited the files under
.plugins/org.eclipse.debug.core/.launches
These all likewise pointed to the JRE instead of the JDK. Once these edits were made, I could build projects in the second workspace from within Eclipse, not just from the command line.
I'm using maven plugin for Eclipse (V3.3) and was struggling with this error for a while. I finally found the solution which is linked to stale java sources: it has nothing to do with JRE or JDK (I use JRE 1.7).
I found on other forums that it is a known problem in maven-compiler-plugin (same result for V3.3 and 3.5.1).
So, I just recompiled manually the stale source(s) and ran again the goal, this time without any problem.
To figure out stale sources, run the goal with option -X (debug) and look for entries beginning with
[DEBUG] Stale source detected:
indicating a java class file (to be recompiled manually...).
Hope this can be useful as the message given by maven compiler made me search in a wrong direction (play with JRE, JDK, JAVA-HOME, etc).
Go to your 'Runtime Configuration' and configure your JRE to an JDK.
Or as @PawanKumarBaranwal suggested, set your default JDK. But care if you have more than one JRE configured.
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:
Then configure the maven run through these steps:
Try this. Go to Window --> Preferences --> Java --> Installed JREs.
Double click the JRE, which is inside installed JREs.
Give the JDK path (for example, C:\Program Files\Java\jdk1.7.0_80\
) in JRE Home, and give JRE name as JDK.
Click on Finish and then OK.
For me it worked.