Generating Java beans from a JAXB Schema
To enable you to map to and from XML data and Java™ objects, you can use the JAXB Schema to Java Bean wizard. The wizard generates Java beans that correspond to your schema.
About this task
To generate beans from a JAXB schema, follow these steps:
Procedure
- Create one or more Java based projects to work with the beans you will generate from your JAXB schema. For example, create a Java, Web, EJB, or Application Client project. Multiple projects can be used to support schema libraries.
- In the Navigator view, right-click the JAXB schema file and click Generate > Java. The Generate Java wizard opens.
- From the Generator list, select JAXB Schema to Java Bean. Click Next.
- On the Select XML Schema page you have the following options:
- Generate schema library: selecting this option will allow you to customize the schema file to project mapping on the next panel.
- In the Target Java Container list, specify the project or folder to contain the generated Java beans.
- In the Target Package field, type a name for the Java package or accept the default value.
- Optional. You can customize the default binding
between an XML schema component and its Java representation
by adding an external binding declaration. In the Binding Files pane,
click Add. Select an external binding declaration
file from a location on your machine and click OK.
(For example, MyJAXBtoBeanBinding.xjb). The binding
compiler uses the binding declarations you specify in the external
file to customize your XML to bean bindings without requiring modification
to your source schema.Note: You can create a binding file using any text editor. The format of your file must conform to the JAXB 2.x specification for external binding declarations.
- If you have chosen to generate a schema library, click Next and customize the mappings between XSD documents or groups of XSD documents to a project.
- Click Finish. The beans and classes appear in the Navigator view in the location you specified. Double-click them to edit them in the Java or Class editor.

