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 m
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.
I tried all the things; the one that worked for me is:
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.
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
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>