2 Replies Latest reply on Dec 10, 2009 8:15 PM by 843793

    javax.annotation.processing.Processor not recognized


      I'm currently experimenting with the javax.annotation.processing API. Thus I created a simple Annotation and a related simple processor.
      Another sample program uses the annotation. When compiling this program everything works fine as long as I specify the processor class
      on the command line. But when I try to simply use a javax.annotation.processing.Processor file, the compiler doesn't seem to find the processor.

      What am I doing wrong?

      Here come the details:

      I use Java6 and the sun java compiler javac.
      The annotation and processor class are packed into a JAR file together with the javax...Processor file. The JAR looks like this:
           The javax.annotation.processing.Processor file is UTF-8 encoded and contains a single line:
      without the leading spaces.

      My processor looks like this:
           @SupportedAnnotationTypes (value = {"hello.annotations.Hello"})
           public class HelloProcessor extends AbstractProcessor {
               private int mCounter = 0;
               /* (non-Javadoc)
                * @see javax.annotation.processing.AbstractProcessor#process(java.util.Set, javax.annotation.processing.RoundEnvironment)
               public boolean process(Set<? extends TypeElement> aAnnotations, RoundEnvironment aRoundEnv) {
                Messager vMessager = processingEnv.getMessager();
                vMessager.printMessage(Kind.NOTE, "Runde " + ++mCounter);
                vMessager.printMessage(Kind.NOTE, "Hello World!");
                return false;
      The following call works...
      javac -processor hello.HelloProcessor -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.java
      and leads to the following output:
      warning: No SupportedSourceVersion annotation found on hello.HelloProcessor, returning RELEASE_6.
           Note: Runde 1
           Note: Hello World!
           Note: Runde 2
           Note: Hello World!
                And this call does not seem to work:
      javac -d bin -sourcepath src -cp lib/helloap.jar src/hello/examples/SimpleClass.java
      as it does not produce any output.

      And when I try to configure the processor in eclipse, the processor simply is not found, when I define the helloap.jar on the factory path.

      I'd be happy about every hint.