Reputation: 11896
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?
Upvotes: 725
Views: 1557076
Reputation: 2834
Please for windows uses
If you are using intellij, just after adding JAVA_HOME open command prompt from project directory and run mvn clean install(don't use intellij terminal).
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202
Upvotes: 1
Reputation: 453
While building the project, make sure to point the jre to jdk path. This can be done in Run configuration section for the particular project.
Upvotes: 0
Reputation: 311
This is because it is looking for JDK and is founding JRE.
Recommended Solution:
Window > Preferences > Java > Installed JREs > Edit > Click on directory > Browse JDK path....
That should work fine.
It worked fine for me!!
Upvotes: 1
Reputation: 193
For me, I had upgraded to Big Sur Mac OS and I had to remove this and then it worked fine.
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
Upvotes: 1
Reputation: 735
In Linux, doing a docker example, I must not have had the JDK installed just the JRE. After sudo apt install openjdk-8-jdk
and setting JAVA_HOME in profile and adding JAVA_HOME/bin to the path, it built!
Upvotes: 2
Reputation: 818
right click on your project and run as maven install then again run your application. if this didnt work go to the folder of your project directly start command line and run 'mvn install'
Upvotes: 0
Reputation: 557
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, OR 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\
Upvotes: 1
Reputation: 6168
Though the question is about the error with Eclipse
setup but thought an answer of fixing this error with IntelliJ
and Windows 10 setup may also be helpful here.
1. Go to File
--> Settings
--> Build, Execution, Deployment
--> Build Tools
--> Maven
--> Importing
2. Set JDK
for Importer
as shown below to JAVA_HOME
Also JAVA_HOME
should be set to JDK
path at Environment Variables --> System variables and also add %JAVA_HOME%\bin
to Path System variables
Upvotes: 7
Reputation: 89
I tried most of the answers without success. What worked for me was (after following https://stackoverflow.com/a/21279068/2408893):
Upvotes: 3
Reputation: 211
Problem statement = No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK? intellij
Solution
Please set the Environment variable like below to solve the issue
Variable name : JAVA_HOME
Variable Value : C:\Program Files\Java\jdk1.8.0_202
Variable name : M2_HOME
Variable Value : C:\Program Files\apache-maven-3.6.0
Moreover, Add Java and maven path in "System Variables" like below:
C:\Program Files\Java\jdk1.8.0_202\bin
C:\Program Files\apache-maven-3.6.0\bin
Upvotes: 7
Reputation: 39
I went to Preferences --> Java --> Installed JREs I did NOT see the JDK in here. I only saw the JRE here. So I added the JDK.
here we have to mandatory remove JRE instead of just unchecking.
Upvotes: 1
Reputation: 10362
JAVA_HOME
environment variable to the JDK root folder - required if you run command line or maven (mvn
).
JAVA_HOME
for more info)Upvotes: 152
Reputation: 121
My answer pertains to the Eclipse in Windows environment.
I went to Preferences --> Java --> Installed JREs I did NOT see the JDK in here. I only saw the JRE here. So I added the JDK and then unchecked the JRE. Then checked JDK. Then I ran the POM file using Run Configurations. Choose the tab JRE and select the option "Workspace Default..." Here are the images
Upvotes: 11
Reputation: 400
I was getting the same error when I created a new EC2 ubuntu 16.04 instance with Java already installed on it and while running mvn clean package, I encountered this issue and the below solution worked for me.
If you are working on an Ubuntu server, then you can try installing Java again and for that you can use this answer How to install the JDK on Ubuntu Linux
Upvotes: 1
Reputation: 2845
I got same issue and i just add JAVA_HOME
to environment variables.
JAVA_HOME
open command prompt from project directory and run mvn clean install
(don't use intellij terminal).Upvotes: 23
Reputation: 71
In my case I had system variable path has "C:\ProgramData\Oracle\Java\javapath" location.
In "C:\ProgramData\Oracle\Java\javapath" location java, javaw only there. So I am getting the same error.
Once I removed all files in "C:\ProgramData\Oracle\Java\javapath" folder my error got resolved.
Upvotes: 2
Reputation: 1840
For me the JRE was in the PATH environment variable before the JDK path
So I removed 1. Probably swapping them would fix it too.
Upvotes: 5
Reputation: 448
I just wasted 3 hours with this problem until I managed to make it work. I had this error in the Eclipse Terminal when issuing a mvn compile command:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
So I read here that I have to make a new system variable called JAVA_HOME and make it point towards the jdk installation folder. However this generated another error:
Source option 1.5 is no longer supported. Use 1.6 or later
Couldn't find a fix for this one so...
So the fix to make it all go away is install Java SE Development Kit 8! I was using 9 thinking that if it's the latest it must be better...
Anyway...
Install JDK8 from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Then define the JAVA_HOME system environmental value - tutorial here: https://docs.oracle.com/cd/E19509-01/820-3208/inst_cli_jdk_javahome_t/
Restart Eclipse and enjoy! (at least that's what I did)
Hoping this spares some poor wanderer of some trouble.
Upvotes: 2
Reputation: 1964
I faced the same issue while trying to build a jar file of my project application using mvn clean install
, though the application was working fine while running from Eclipse.
The issue was, indeed too naive, that I had not set the JAVA_HOME environment variable. All I had to do is set JAVA_HOME environment variable to JDK directory, make sure it is not till "\bin" and without semi-colon ";".
How I understood it is as:
The application worked fine in Eclipse as JRE System Library was referring to JRE inside the JDK folder instead of external JRE folder without JDK. [As explained very well in other answers]
This configuration does not apply to maven command that we run on command prompt. It will still look for JAVA_HOME variable to access the JRE System library and when it is not found it refers to external JRE folder without JDK.
Upvotes: 11
Reputation: 460
Are you missing any maven build.
Apart from above JRE changes.I still faced similar issue.I was missing JUnit dependency after adding it is working fine.
Hope this will help.
Upvotes: 0
Reputation: 11997
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
Upvotes: 1087
Reputation: 261
I got a solution.
The most common solution for this problem is to change jdk location as my Installed JREs instead of the JRE location but that did not solve my problem this one time.
So I did the below to solve the problem. Expand the Installed JREs tab and you will find a Execution environments tab.
Click on your favourite execution environment. In my case it was JAVASE-1.8. There it shows 2 options. JDK and JRE. Select JDK there and the problem is solved.
Upvotes: 3
Reputation: 595
There are several answers regarding this question but all are related to right path configuration of JDK, but with JRE only we can solve this problem.
We just need to make use of deployment assembly to configure the path of packaged war file of the Java EE Project and then re-run the maven-install.
Steps to make use of deployment assembly:
Right click on the Jave EE project --> click on Properties --> click on Deployment Assembly
Click on Add button --> Click on Archives from the File System --> Click on next --> Click on Add --> Go to the .m2\respository directory and search for the war file generated --> Select war file --> Click on Open button --> Click on Apply --> OK
Right click on the project --> Click on Maven Install under Run As
This will build your project successfully, without any compiler error.
Hope this solves the problem without JDK.
Upvotes: 0
Reputation: 450
There are several options to specify.
Steps: Right on project in project explorer Go to Run-> Run Configuration -> Click Maven Build -> Click on your build config/or create a new config. You will see the window as the given snapshot below, click on JRE tab there.
You see you have 3 options 1) Workspace Default JRE 2)Execution Environment 3)Alternate JRE 1) Workspace Default JRE is set from 'Window' menu on the top -> Preferences -> Java -> Installed JREs -Here you can add your jdk 2) Execution Environment jdk can be set in pom.xml as mentioned by @ksnortum
<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>
3) Alternate JRE can be used to select a jdk from your directory
Upvotes: 7
Reputation: 871
Go to windows -> Preferences -> Java -> Installed JREs
click on Add -> Standard VM -> Next -> Directory
and browse for the JDK
in my case path was C:\Program Files\Java\jdk1.8.0_111
then Click on finish.
select JDK -> Apply -> Ok
And You are done.
Upvotes: 37
Reputation: 541
I tried all of the above, however, still getting the same error message.
In my case an actual JRE was incorrectly used as JRE System Library in the project-specific build path which was obviously overriding all those other settings discussed here.
If that is so in your case try the following:
Upvotes: 14
Reputation: 11
Try this.
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable> path to jdk \bin\javac.exe</executable>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 1
Reputation: 419
If you are running the Maven
command from cmd
, make sure you set the jdk path before running the command. In my case, I have created a .bat
file containing the following:
set JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
start cmd.exe /k "cd c:\aem_proj\sis\aau"
Upvotes: 11
Reputation: 3696
In addition to answer above, I could say that just try to run Maven from the terminal (outside of Eclipse). In this way, if it builds from outside but not in Eclipse, you can understand that the problem should be in Eclipse.
Upvotes: 0