One may see following error for the first time when maven project is tried to be run using POM -
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Json: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Problems is about setting JRE version in eclipse/setting javac in POM.
To fix the eclipse to run Maven test -
1. Go to Installed JREs in following way through Eclipse Menu options
Menu ->Windows->Preferences->Installed JREs.
2. Select/Add Installed JRE
Another Approach -
To fix the POM - Set Maven-compiler-plugin
Reference -
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project Json: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
Problems is about setting JRE version in eclipse/setting javac in POM.
To fix the eclipse to run Maven test -
1. Go to Installed JREs in following way through Eclipse Menu options
Menu ->Windows->Preferences->Installed JREs.
2. Select/Add Installed JRE
Another Approach -
To fix the POM - Set Maven-compiler-plugin
Reference -
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.5.1</version>
- <configuration>
- <verbose>true</verbose>
- <fork>true</fork>
- <executable><!-- path-to-javac --></executable>
- <compilerVersion>1.3</compilerVersion>
- </configuration>
- </plugin>
- </plugins>
- </build>
Some times, in-appropriate testng version causes issue.
For example I got following issue with 6.9.13.6 -
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project Json: Execution default-test of goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ? -> [Help 1]
The complete stack trace was -
org.apache.maven.surefire.util.SurefireReflectionException: java.lang.reflect.InvocationTargetException; nested exception is java.lang.reflect.InvocationTargetException: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.apache.maven.surefire.testset.TestSetFailedException: Unknown TestNG version 6.9.13.6
at org.apache.maven.surefire.testng.TestNGExecutor.getConfigurator(TestNGExecutor.java:207)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:72)
at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:110)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:106)
... 9 more
Solution -
TestNG version 6.9.9 worked well for me.