How to generate xml schema xsd from java class using jaxb in eclipse

Let us discuss how to generate or create xml schema xsd from java class using jaxb in eclipse with below example.

Steps:

1. Create a new JAXB project. File -> New -> Other -> JAXB -> JAXB Project.
jaxb1
 
2. Enter the project name and click on Finish button.
jaxb2
 
3. Download JAXB Jar and JAXB-XJC jar files and include in class path.
jaxb11
 
4. Create package which will contain xsd file.
jaxb3
 
5. Create package which will contain java classes.
jaxb4
 
6. Create a java class. Here we are using the java classes generated from previous example.
jaxb12
 
7. Right click on your package -> New -> Other -> JAXB -> Schema from JAXB Classes and click on Next.
jaxb13
 
8. Specify file name and location for new xsd file and click on Next.
jaxb14
 
9. Select java classes from which schema have to generated and click on Finish.
jaxb15
 

On Console:

loading...
com.javawithease.javaclass.Address
com.javawithease.javaclass.ObjectFactory
com.javawithease.javaclass.Student
generating schema...
Schema 
D:\TestWorkspace\JAXBXSDTest2\src\com\javawithease\xsd\test1.xsd 
generated

Download this example.
 
Previous Topic: How to generate java class from xml schema xsd using jaxb in eclipse.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.