How to use an annotation processor which depends on java.xml.bind?

Anthony Vanelverdinghe anthony.vanelverdinghe at
Tue May 16 17:30:26 UTC 2017


Given an annotation processor, JaxbProcessor, and a simple source file,, as below.

First I compile with:
javac --add-modules java.xml.bind
or, by using the JAXB RI:
javac --upgrade-module-path .

But I can't find out how to compile with the JaxbProcessor, 
i.e. how to replace the dots to make this succeed:
javac ... -processor JaxbProcessor

No matter what I try, it gives me: java.lang.NoClassDefFoundError: 

So how can I use an annotation processor which depends on one of the 
modules that is not resolved by default?

Kind regards, Anthony


public interface Test { void test(); }


import java.util.Set;
import javax.annotation.processing.*;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.TypeElement;
import javax.xml.bind.JAXB;

public class JaxbProcessor extends AbstractProcessor {

     public boolean process(Set<? extends TypeElement> set, 
RoundEnvironment re) {
         JAXB.marshal("hello", "world");
         return true;

     public SourceVersion getSupportedSourceVersion() {
         return SourceVersion.latestSupported();


More information about the compiler-dev mailing list