No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Question
I'm compiling a project in Eclipse using m2eclipse. I set the JDK path in Eclipse like this:
Windows-->preferences-->installed jres--> jdk1.7.xx path
But this is showing an 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: 1.424s
[INFO] Finished at: Tue Oct 29 15:21:01 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler- plugin:3.1:compile (default-compile) on project TEST-WEB: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Accepted Answer
- On your Eclipse IDE, go into Window > Preferences > Java > Installed JREs > and check your installed JREs. You should have an entry with a JDK there.
- Select the Execution Env as show below. Click OK
- Then Right-Click on your Project -> Maven -> Update Project
Additionally, you may have to change Maven JRE (see @jlars62 answer) which is as follows. Goto Run -> Run Configurations, selecting the Maven Build I was running (from the left panel). Then, I clicked the JRE tab and selected the option Workspace default JRE
Read more… Read less…
For me, it is exactly what the maven of eclipse complains
So, I press Edit
button and change path to the JDK Folder, then clean project and everything starts to work
- Set the
JAVA_HOME
environment variable to the JDK root folder - required if you run command line or maven (mvn
).- (Search google for
JAVA_HOME
for more info)
- (Search google for
- In project properties in section Java Compiler select required JDK - if you run directly from eclipse
For me, nothing worked until I made this change to my pom.xml:
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>
Other Notes
I could see that m2e was executing in a JRE, not the JDK. Nothing I did changed this, including adding this to the eclipse.ini:
-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
In the end I never got m2e to execute in a JDK, but setting the Java compiler explicitly (as above) did the trick.
In my case it was solved by doing this:
Go to your 'Runtime Configuration' and configure your JRE to an JDK.
I copied answer just in case it is deleted for some reason, but the source is here
I was getting this error when trying to do a maven build from within eclipse.
For me, the answer was going to Run
-> Run Configurations
, selecting the Maven Build
I was running (from the left panel). Then, I clicked the JRE
tab and selected the option Workspace default JRE