JAXB - Generate Stubs from XSD

This article describes the method of generating the JAXB Stubs from the XML schema using ANT build.

Consider the following ANT build xml which reads the XML schema from "C:\Sample.xsd" and generates the JAXB stubs in the "C:\jaxbSrc" location.

<?xml version="1.0" encoding="UTF-8" ?>

<project basedir="." default="build" name="Jaxb-StubGenerationDemo">

        <taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
          <classpath>
            <fileset dir="C:\lib\" includes="jaxb-xjc.jar" />
          </classpath>
        </taskdef>

    <target name="build">
        <xjc schema="C:\Sample.xsd"
                        destdir="C:\jaxbSrc"
                        package="com.jaxb.test"/>
    </target>
</project>

Note: Place jaxb-xjc.jar inside C:\lib\ directory.

Technology: 

Search