com.sun.mirror.apt API
I'm new to Java and I am getting an error v开发者_Go百科ia Eclipse on the following lines:
import com.sun.mirror.apt.AnnotationProcessorFactory;
import com.sun.mirror.apt.AnnotationProcessor;
import com.sun.mirror.apt.AnnotationProcessorEnvironment;
The error is "The import com.sun.mirror cannot be resolved".
How do I fix this error?
To the point: just put it in the classpath (buildpath, in Eclipse). You can download it here.
However, this use is not really recommended. Rather use the standard API classes and methods in the javax.annotation.processing
API which are already inside the standard Java SE API. It will "behind the scenes" use the right classes for the desired tasks.
Deprecated
apt tool and API have been deprecated as of JDK 7. Mention on: https://blogs.oracle.com/darcy/entry/apt_api_files
To resolve you can import tools.jar %JDK JAVA%\lib\tools.jar.
In my case "C:\Program Files\Java\jdk1.7.0_01\lib\tools.jar"
also the answer by BalusC is correct but the link is dead and there is simpler solution in Sun JDK both 1.5 and 1.5 there is tools.jar in the /lib/ add it to the class path it all there.
Though it's deprecated ,if you want to give it a try like dealing with a sample of a book,you may download the zip file of apt-mirror-api-0.1.jar
here, and then just build path in your IDE. For eclipse,just right click the JRE System Library
-->Build Path
-->Configure Build Path
-->Add External JARs
and finally find your downloaded jar file and apply it.
精彩评论