Home » JAXB Tutorials

JAXB Tutorials

JAXB TUTORIALS

In this detailed Resource page, we feature JAXB Tutorials!

Java Architecture for XML Binding (JAXB) is a software framework that allows Java developers to map Java classes to XML representations. JAXB provides two main features: the ability to marshal Java objects into XML and the inverse, i.e. to unmarshal XML back into Java objects. In other words, JAXB allows storing and retrieving data in memory in any XML format, without the need to implement a specific set of XML loading and saving routines for the program’s class structure. It is similar to xsd.exe and XmlSerializer in the .NET Framework.

JAXB is particularly useful when the specification is complex and changing. In such a case, regularly changing the XML Schema definitions to keep them synchronised with the Java definitions can be time consuming and error-prone.

JAXB is a part of the Java SE platform and one of the APIs in the Java EE platform, and is part of the Java Web Services Development Pack (JWSDP). It is also one of the foundations for WSIT. As of Java 11, JAXB will be removed from the Java SE platform and moved to the Jakarta EE project. For details, see JEP 320.

JAXB 1.0 was developed under the Java Community Process as JSR 31. In 2006 JAXB 2.0 was released under JSR 222 and Maintenance Release 2 released in December 2009. Reference implementations for these specifications are available under the CDDL open source license at java.net.

Usage

The tool “xjc” can be used to convert XML Schema and other schema file types (as of Java 1.6, RELAX NG, XML DTD, and WSDL are supported experimentally) to class representations. Classes are marked up using annotations from javax.xml.bind.annotation.* namespace, for example, @XmlRootElement and @XmlElement. XML list sequences are represented by attributes of type java.util.List. Marshallers and Unmarshallers are created through an instance of JAXBContext.

In addition, JAXB includes a “schemagen” tool that can essentially perform the inverse of “xjc“, creating an XML Schema from a set of annotated classes.

Note
If you wish to build up your JAXB knowledge first, check out our JAXB Tutorial for Java XML Binding – The ULTIMATE Guide.

JAXB Tutorials – Getting Started

Simple examples based on Java Architecture for XML Binding

JAXB Tutorials – Integrations

Learn how to use JAXB with RESTEasy and Jettison

  • JSON Example With RESTEasy + JAXB + Jettison
    In this tutorial we are going to see how you can integrate RESTEasy with Jettison to develop JAX-RS RESTful services that produce and consume JSON streams.
  • XML Example With RESTEasy+ JAXB
    In this example we are going to see how you can integrate RESTEasy with JAXB (Java Architecture for XML Binding) to create RESTful services that consume and produce XML streams.
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy