title: How to generate an XML schema file from (JAXB) annotated Java classes, using JDK8
body: <p>The instructions to generate schema through running "schenagen" as suggested in Java API documentation worked with JDK7, but not with JDK8.</p>
  
  <p>Here is the documentation page:
  <a href="http://download.java.net/jdk8/docs/technotes/guides/xml/jaxb/index.html" rel="nofollow noreferrer">http://download.java.net/jdk8/docs/technotes/guides/xml/jaxb/index.html</a></p>
  
  <p>Here is the line from this page with links to the instructions:</p>
  
  <p>"
  Running the schema generator (schemagen):<a href="https://jaxb.java.net/2.2.4/docs/schemagen.html" rel="nofollow noreferrer"> [command-line instructions</a>, <a href="https://jaxb.java.net/2.2.4/docs/schemagenTask.html" rel="nofollow noreferrer">using the SchemaGen Ant task]
  </a>
  "</p>
  
  <p>Schema generator does not work because some classes have been removed from JDK8:
  "java.lang.ClassNotFoundException: com.sun.mirror.apt.AnnotationProcessorFactory"</p>
  
  <p>There is another solution suggested here:
  <a href="https://stackoverflow.com/questions/7251458/generating-xsd-schemas-from-jaxb-types-in-maven">Generating XSD schemas from JAXB types in Maven?</a></p>
  
  <p>This solution also works with JDK7 but not with JDK8; it will end up with a similar error:</p>
  
  <p>"Class not foundcom/sun/tools/apt/Main.class"</p>
  
  <p>The root cause is probably the same: the annotation processing tools are removed from JDK8.
  This change was planned in JEP 117 long time ago:
  <a href="http://openjdk.java.net/jeps/117" rel="nofollow noreferrer">http://openjdk.java.net/jeps/117</a></p>
  
  <p>How can I generate an XML schema file from (JAXB) annotated Java classes now, using JDK8?</p>