I am using Springs for development. And I am using eclipse.Earlier my project was getting built successfully but as I pasted some more files in my application in some packages I am getting following error when I say Run as "Maven Package". I am not understanding why is this error getting in between some times.
I get following error when I say Run as Maven package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HeyLets 0.8-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ HeyLets ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ HeyLets ---
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\temp\temp_wsp\HeyLetsNew\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
C:\Program Files\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.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.156s
[INFO] Finished at: Fri Feb 25 11:04:37 IST 2011
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project HeyLets: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files\Java\jre6\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment var开发者_开发技巧iable.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
I fixed the problem by following the instructions in the thread pointed by Raghuram. You got to change the used JRE to the one inside the JDK.
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
".
Run your maven script again, and as you can see, problem is solved!
[ERROR] Unable to locate the Javac Compiler in: C:\ProgramFiles\Java\jre6..\lib\tools.jar
Use jdk jre: C:\Program Files\Java\jdk1.6.0_27\jre ($BaseDir)
Now path jre\..\lib\tools.jar is right. (.. mean parent directory)
$BaseDir\jre\..\lib\tools.jar equal $BaseDir\lib\tools.jar
In Eclipse go to Windows -> Preferences - > Java -> Installed JREs
and add or change the location to "C:\Program Files\Java\jdk1.6.0_27\jre" or something like that.
Perhaps you are facing the same problem discussed in this thread. If so, a workaround is suggested in the thread as well.
精彩评论