No com.sun.tools.javac in JDK7

java, java-6, java-7

Solution

It looks like you are using Eclipse. By default Eclipse only imports JRE jars, not the ones from the JDK.

Solution 1:

- Go to Eclipse preferences (on Windows: Window-->Preferences)

- Open the preference Java-->Installed JREs

- Select your JRE and press edit

- Use "Add external jars" to include the tools.jar (found in JDK_HOME/lib)

Solution 2:

Edit your project build path and add an external library: tools.jar found in JDK_HOME/lib

Problem

I'm using JDK7 and Eclipse Indiago in Windows 7 64-bit. I set environment variable JAVA_HOME to F:\JDK7 and add %JAVA_HOME%\bin in path. It's my sample code: ``` com.sun.tools.javac.Main m1 = new com.sun.tools.javac.Main(); m1.compile(source); ``` Error I get: Type com.sun.tools cannot be resolved to a type Why there is no com.sun.tools ? What's the problem ?

Original source