Ellen Spertus
Ellen Spertus

Reputation: 6805

How to specify an AbstractProcessor on the apt/javac command line?

I have a class that extends javax.annotation.processing.AbstractProcessor, which I'd like to run over some .java files with apt.

How do I specify the class name on the apt command-line (or in an ant apt task)? The command-line options I see, such as -factory expect an AnnotationProcessorFactory, not an AbstractProcessor.

Upvotes: 1

Views: 732

Answers (1)

emory
emory

Reputation: 10891

I use javac 1.6.0_20.

The relevant options for my compiler are

  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files

I suspect you are using javac 1.5.*. That JDK does not work with AbstractProcessor (which was introduced in 1.6). The solution is to upgrade your JDK.

Upvotes: 4

Related Questions