I am a relative newcomer to the world of Java enterprise development. My organization's Java guru is out on indefinite family leave, and I have been assigned the task of maintaining some of the Java applications he developed. He setup Eclipse [Kepler SR1] with Maven on my computer before he left, and it appeared to work ok.
Now I'm ready to deploy my first modification and need to run a Maven install
, but I am having trouble getting it to work - I get the following output on my console:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mrpapp: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
but I definitely am running a JDK and not a JRE. I double-checked my $JAVA_HOME
(C:\Program Files (x86)\Java\jdk1.7.0_60
) and it does have a javac.exe
in its bin
directory.
I am attaching a copy of my pom.xml
file for your review. I'm sure there is something in there that is causing the problem, but I am not sure what it might be. I am using a laptop with Windows 7 64bit, if you need any further platform/environment info I can supply that as well.
Any help will be greatly appreciated.
When I was runing mvn compile
, I was getting below error in console:
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1087 source files to C:\Code\DevVNextComplete\Development_vNext\Source\JARS\target\classes
[INFO] -------------------------------------------------------------
[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
[Resolution]
I had added, the JAVA_HOME variable in my environment variables and then it worked.
For me (on windows 10), I was getting the error "No compiler is provided in this environment" at the Windows command prompt when I ran mvn install
. The fix was changing the JAVA_HOME environment variable to point to my jdk (C:\Program Files\Java\jdk1.8.0_101); previously it had pointed to the jre.
And to get Eclipse to use the new jdk, I edited eclipse.ini
in my eclipse distribution and changed the line for -vm
to C:\Program Files\Java\jdk1.8.0_101\bin
.
I also faced similar error when I was working with Jdk1.8_92. For me, I found tools.jar was missing in my jdk folder. Since I was running in console, I couldn't try the options of eclipse suggested by others..
I installed jdk-8u92-windows-x64. After I tried all options, I observed that tools.jar was missing in jdk1.8.0_92/lib folder. I copied tools.jar from my older version of java. Then It was able to compile.
To check what your Maven uses, open a command line and type:
mvn –version
Verify that JAVA_HOME refers to a JDK home and not a JRE
On Windows:
Go to System properties -> Advanced system settings -> Advanced -> environment variable and on the System variables section select the JAVA_HOME variable and click on Edit Fill the form with the following Variable name: JAVA_HOME Variable value:
On Unix:
export JAVA_HOME=<ABSOLUTE_PATH_TO_JDK>
see this link
Installed JRE In my case I solved the problem by removing duplicates of names, I kept only one with the name: jdk.1.8.0_101
Follow : Windows --> Preferences --> Java ---> Installed JREs
Click on "Search.."
Navigate to C drive ---> Program files
Eclipse will find all the jre's and jdk's --> select one of the jdk and select Apply
If you are using maven include the following tag in pom.xml (update versions as needed) inside plugins tag.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
Go into Window > Preferences > Java > Installed JREs > and check your installed JREs. You should have an entry with a JDK there.
Maven requires JDK to compile. In Eclipse you need to CHANGE/ REPLACE your JRE to the JDK path that your JAVA_HOME points to. Navigate to Window > Preferences > Java > Installed JREs.
Make sure that the maven-compiler-plugin in you pom.xml has the source and target of the java version in your JAVA_HOME
http://learn-automation.com/maven-no-compiler-is-provided-in-this-environment-selenium/
was getting the same problem, pointed java to bin folder in eclipse using: windows > preferences > java > installed JREs > remove any existing JRE and point it to your java bin folder (mainly under C:\Program Files\Java\jdk1.8.x_xx).
then run maven install it should work.
if someone is running Eclipse in Ubuntu and have this problem I have found the answer by following these steps:
I was getting the same error when trying to execute a maven build within Eclipse in a newly installed Eclipse Neon (for JEE devs) installation, on Windows 10 with JDK 8 and JRE 8 installed.
I had tried specifying tools.jar as an external lib, as well as setting the jdk as the -vm in eclipse. Neither of these things worked.
Selecting the JDK as the default execution env as mentioned above did the trick..
The text above the compatible JREs listbox in step 3 says "a default JRE can be specified by checking it"
Note: I also have the maven compiler plugin explicitly listing 1.8 in the pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
I had a problem with Eclipse Neon where the workspace default did not actually change even though I added the correct location under Preferences->Java->Installed JREs. This was in a new workspace I created to work on a code branch; it was originally set to the JRE location rather than the JDK. Yet even after changing the preferences, I could build with the command line, yet building in Eclipse produced the no compiler error. Please see
Maven Package Compilation Error
for my answer on which Eclipse configuration file(s) had to be manually edited to make Eclipse recognize the correct workspace default. I still have no idea why the preferences setting did not carry through to the new workspace's configuration.
Make sure you have %JAVA_HOME%
set by typing echo %JAVA_HOME%
in Command Prompt. If you don't have that set, then you need to go add your Java path to Window's Environmental Variables.
Screen_shot Add 'tools.jar' to installed JRE.
Eclipse
-> window
-> preference
.installed JREs
-> Edit
tools.jar
from java/JDKx.x/lib
folder.Please check if you have the following entries in the element of your pom.xml especially the jdk.version because switching to an installed jre did not fix me the similar error.
<properties>
<jdk.version>1.7</jdk.version>
<spring.version>4.1.1.RELEASE</spring.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.11</junit.version>
</properties>
Add this configurations in pom.xml
<project ...>
...
<build>
...
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<fork>true</fork>
<executable>C:\Program Files\Java\jdk1.7.0_79\bin\javac</executable>
</configuration>
</plugin>
</plugins>
</build>
...
</project>
1.Go to Windows-->Preferences-->Java-->Installed JREs-->Execution Environments
2.select the java version you are using currently in the "Execution Environments" box. So that in the "Compatible JREs" box, you are able to see as "jre1.8.0_102[perfect match]"(if your java version is 1.8). Then try to build using maven.
In my case, I had created a run configuration and whenever I tried to run it, the error would be displayed. After searching on some websites, I edited the run configuration and under JRE tab, selected the runtime JRE as 'workspace default JRE' which I had already configured to point to my local Java JDK installation (ex. C:\Program Files (x86)\Java\jdk1.8.0_51). This solved my issue. Maybe it helps someone out there.
I tried all the things; the one that worked for me is:
if you are working outside of eclipse in the command window
make sure you have the right JAVA_HOME and that that directory contains the compiler by entering the following command in the command window:
dir %JAVA_HOME%\bin\javac.*
check java version in pom.xml and jre version in Eclipse->Window->Preferences->Installed JREs. In my case pom.xml has different version(it had 1.8 while eclipse using 1.7). Fixing the version in pom.xml to 1.7 worked.
Source: Stackoverflow.com