Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Package Compilation Error

Tags:

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 : [INFO] ------------------------------------------------------------- [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? [INFO] 1 error [INFO] ------------------------------------------------------------- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.310s [INFO] Finished at: Tue Mar 05 14:32:23 IST 2013 [INFO] Final Memory: 16M/218M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.0:compile (default-compile) on project  Compilation fa ilure [ERROR] ***No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?*** [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 tried to change jdk and jre. but not working. still it shows same error

like image 882
Shiju K Babu Avatar asked Mar 05 '13 09:03

Shiju K Babu


People also ask

How do I resolve MojoExecutionException?

The MojoExecutionException should not appear after that. Some Eclipse versions have this problem to refresh the target folder. In this case, Refresh the project just after the "Maven Install".

What is compilation in Maven?

The compiler plugin is used to compile the source code of a Maven project. This plugin has two goals, which are already bound to specific phases of the default lifecycle: compile – compile main source files. testCompile – compile test source files.


2 Answers

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, OW 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\
like image 112
Sym-Sym Avatar answered Sep 21 '22 13:09

Sym-Sym


Go to your 'Runtime Configuration' and configure your JRE to an JDK.

Select the right JDK for your Runtime

Or as @PawanKumarBaranwal suggested, set your default JDK. But care if you have more than one JRE configured.

Select default JRE

like image 27
kdoteu Avatar answered Sep 21 '22 13:09

kdoteu