Search code examples
javaeclipsemavenmaven-checkstyle-plugin

Import Maven projects in Eclipse has error occurred that caused by couldn't find tools.jar


Error like the screen capture shows below occurred when I tried to import "Existing Maven Projects" with maven-checkstyle-plugin in Eclipse Oxygen. It looks like that Eclipse using default JRE path other than the JDK one which I had set in both environment variables and "JRE Installed" config in Eclipse.

The error occurred when I imported Existing Maven Projects with maven-checkstyle-plugin in Eclipse Oxygen

Full stack trace of exception found in "Error" View in Eclipse: Full trace stack of exception

My Environment Variables setting:

JAVA_HOME setting

CLASSPATH setting

The user level setting of "Path" variable : The user level setting of "Path" variable

System level setting of "Path" variable:

System level setting of "Path" variable

Installed JREs setting in Eclipse: Installed JREs setting in Eclipse

Installed JREs setting in Eclipse2

Projects I tried to import was cloned from github, the repository url is https://github.com/scribejava/scribejava

I had searched for an answer on internet for two days.. On the official website I found this: https://maven.apache.org/plugins/maven-eclipse-plugin/trouble-shooting/jdk-being-used-is-different-than-expected.html , but it also hasn't solved my problem.

I have run maven install on the parent project after importing finished, there is no error on all stages. The error occurs just during the first importing progress. And it also goes well without any errors when I import project again in a new workspace after I remove checkstyle plugin in pom.xml.

So I guess that there maybe something wrong with the settings of my develop environment. This error doesn't affect any further operations after running maven "install" on project manually, but I really want to know why this happened and it will be the best if I can get rid of it. Thanks!


Solution

  • I have solved the problem. I checked all configurations again, then I noticed that there is a setting entry "C:\ProgramData\Oracle\Java\javapath" in Path variable of System Level which may be the causes of the problem. As I had never set that before. I thought that it is added automatically by JRE installation process perhaps. I run "where java" in cmd console, both "C:\ProgramData\Oracle\Java\javapath" and "C:\Java\jdk8\bin" showed in result list with the "C:\ProgramData\Oracle\Java\javapath" entry on the top of list. Finally all problems gone after I removing "C:\ProgramData\Oracle\Java\javapath" from Path Variable.