m2eclipse is unable to locate C:\\Program Files\\Java\\jre6\\..\\lib\\tools.jar

自闭症网瘾萝莉.ら 提交于 2019-12-03 16:55:06
  1. Go to Windows --> Installed JREs
  2. select the installed JRE and click edit
  3. change the JRE home directory to PATH_TO_YOURJDK\jre (previously it would be PATH_TO_YOUJRE)
  4. this works for me

I figured out a workaround that seems to work. It's not really that what I hoped to be a solution but at least I can use maven now.

I created a new folder on the same level in the file system as the jdk and the jre folders are. I called it lib and copied the tools.jar file form the jdk into it.

Additionally I switched from the "normal" eclipse for java SE to the eclipse for Java EE (I'm using EJBs). The version of eclipse is the one we got from university so i don't know if a plugin is installed which I missed to install on my (java SE) eclipse.

Now It seems to work but if anybody has a solution that might solve that problem in a more elegant way please let me know.

peter.murray.rust

See this answer. It suggests that you need to set your PATH to point to the Java bin directory. In my own case this is set:

D:\workspace>echo %PATH%
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem; ...
C:\Program Files\Java\jdk1.7.0_02\bin; ...

EDIT: You mentioned you have the JRE in your JDK referenced in your build path. Well did you notice that tools.jar is NOT in this JRE folder either? tools.jar is contained in the /lib folder only. Not the JRE inside the JDK.

This kept popping up for me in my project as well. For whatever reason, Eclipse keeps telling me it's unable to locate tools.jar. I have fixed it a few time for this project and tonight it came back. Below is how I ended up fixing it once and for all.

The reason is that you have JRE6 in your included libraries in your Java Build Path. However tools.jar is not included in any JRE, you need to import tools.jar from your JDK.

By simply going to Properties for -> Java Build path -> Libraries (Tab) -> Add External JARs.. and choosing your JDKs tools.jar file in the /lib folder, it fixes the problem. See the image below.

I notice this is already an old question, but there is a better solution for this. First of all, Eclipse ask "Installed JREs", but actually you should provide the JDK here. Like Styler kind of mentioned, but instead of importing the tools.jar separatedly just define the JDK in "Installed JREs". Then it will find everything there is needed from "basic java" without extra imports to build path (also you should not move anything to or from the JDK folder, this can break the portability of the software). Also notice that when selecting "project" > "Java Compiler" there is an option: "Enable project specific settings". If you have this option selected, it may have a different "JRE" specified to be used than what you have in "Window" > "Preferences" > "Java" > "Installed JREs" selected as default.

The problem is in definition of your JAVA_HOME

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24

When it should be

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24\jre

The variable JAVA_HOME should point to Java Runtime directory.

Below are the list of steps that had helped me to solve the issue.

STEP 1:"Properties"(window):

Right-Click on your project->Properties->Java Build Path->JRE System Library(select)-> Edit.

STEP 2:"JRE System Library"(Window):

Alternate JRE(Select and choose the JRE)-> Installed JREs(Click).

STEP 3: "Preferences(Filtered)"(Window)

Select the JRE under 'Installed JRE's' -> Edit(Click)

STEP 4: "Edit JRE"(Window)

Click on 'Add External JARs'

STEP 5: "JAR Selection"(Window)

Select the 'tools.jar' (under JDK->lib) --> 'Open' ->'Finish'-->'OK'-->'Finish' --> 'OK'.

We are good to go!!! Hope this helps..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!