The JRE system library is missing tools.jar

I am using Ubuntu 12.04 (LTS). In my Eclipse project, I need to use the com.sun.tools.attach package. However, my JRE system library does not include the tools.jar file that contains the package.

I tried installing different JREs and JDKs for both Java 6 and 7. I noticed that some of them have the mentioned jar file in their libs folder, but Eclipse still cannot include it in its class path when choosing JRE . Referencing tools.jar directly solves the problem, but since this is a common project, I am not allowed to change the classpath, and therefore this is not a viable solution for me.

My friend uses a MAC with the same version of Eclipse and JRE by default and does not have this problem. What we found out is that for him tools.jar is part of classes.jar, which is not relevant to my setup (I don't have .jar classes at all).

What do you think could be the source of this problem? Any advice would be greatly appreciated.

Thanks guys!!!

+6
source share
2 answers

The problem is that the JDK contains the tools.jar file (none of the JREs).

It is easy to solve the problem, you must specify the default runtime environment to use either for the project or for the entire workspace. Change this to any of the installed JDKs.

The easiest way is probably to go to Window -> Preferences -> Java -> Installed JREs and select the JDK instead of the JRE. All projects use this option by default.

+4
source

I had the same problem on Ubuntu 12.10, and in my case, she was able to solve this problem by adding a link to the current Java binaries folder to my PATH variable.

 PATH="$PATH:/usr/local/java/current/bin" 

or

 PATH="$PATH:$JAVA_HOME/bin" 

Just edit either .profile or .bash_profile in your /home/<user> folder and everything will be fine. If these files do not exist, just create one of them.

Note: make sure you use JDK and not JRE

0
source

All Articles