How to convert xsd to jaxb objects

Wednesday of September 05, 2012

1. Create a valid xsd file, name sample.xsd

<!--?xml version="1.0" encoding="utf-8"?-->
<xs:schema>
<xs:element name="SAMPLEMSG">
    <xs:complexType>
        <xs:sequence>
            <xs:element ref="name"/>
        </xs:sequence>
    </xs:complexType >
</xs:element>
</xs:schema>

2. Your JDK should be JDK1.6 or greater

3. Navigate to %JAVA_HOME%/bin/xjc.exe

4. Open command cosole and type >xjc sample.xsd The jaxb files will be generated ObjectFactory.java and SAMPLEMSG.java

5. Rename the package values of the java files