7

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

2 Answers 2

4

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"
Sign up to request clarification or add additional context in comments.

3 Comments

Unless the problem is in fact the use of the wrong path separator. If so, then that's the answer.
Thanks a lot, I had no idea.
you just saved my life
1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.