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
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"
I also found out that the version of OpenJDK 7 included in Debian Wheezy (7u3) simply does not work with annotation processors. I did a custom build of OpenJDK 7u9 (from Ubuntu Quantal) and it works perfectly.
I reported a bug in Debian's bugtracker: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697658
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With