Blade3
Blade3

Reputation: 4360

com.sun.mirror.apt API

I'm new to Java and I am getting an error via 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?

Upvotes: 5

Views: 10696

Answers (4)

LancelotHolmes
LancelotHolmes

Reputation: 699

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.

Upvotes: 0

Willian Lopes
Willian Lopes

Reputation: 173

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"

Upvotes: 5

Boris Daich
Boris Daich

Reputation: 2461

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.

Upvotes: 1

BalusC
BalusC

Reputation: 1108782

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.

Upvotes: 8

Related Questions