Search code examples
javaannotationsjavacprocessor

Unable to run java annotation processor


I am having troubles running my annotation processor from command line. The problem is that it works in Windows environment, but not on my linux installation.

My processor is located in a jar file (meta-validator.jar). I also added entry to META-INF/services/javax.annotation.processing.Processor containing fully qualified name of class of my processor.

I am trying to invoke annotation processor with this command:

javac -cp "./metadata-validator.jar; ... (path to annotations.jar etc.)" -processor xammt.validator.modules.ValidatorModule -proc:only " ... path to sources" 

In Windows environment it just works (Windows 7 64bit Pro, JDK 1.7.xx), processor is found and process method is executed.

In my linux environment (Linux Mint 13 32bit -> basically Ubuntu 12.04, Oracle JDK 1.7) I get message:

error: Annotation processor 'xammt.validator.modules.ValidatorModule' not found
warning: Annotation processing without compilation requested but no processors were found.

Also without -processor switch I get the same warning (with other verbose stuff).

What could be causing this problem? I guess that my JDK on linux machine is installed correctly, because I am able to run/compile java applications without any problems.

Thanks for any advice.

EDIT: I have still no idea why this does not work. Funny thing is, that it works programmatically - I managed to invoke my annotation processor via Java Compiler API without problems (on both platforms), this is also better solution because of debugging.

EDIT2: Actual command:

javac -cp "./metadata-validator.jar;./lib/common-library.jar;./Annotation source.jar" 
-processor xammt.validator.modules.ValidatorModule -proc:only "SourceFile.java"

SOLVED: check http://en.wikipedia.org/wiki/Classpath_(Java)#OS_specific_notes


Solution

  • On Linux are you using colon instead of semicolon as your class path separator? Include the Linux command you are executing as well.

    Change the semi-colons to colons in the classpath and it should work.

    Like this:

    javac -cp "./metadata-validator.jar:./lib/common-library.jar:./Annotation source.jar" -processor xammt.validator.modules.ValidatorModule -proc:only "SourceFile.java"