Jakarta XML Binding (JAXB; formerly Java Architecture for XML Binding) is a
software framework
In computer programming, a software framework is a software abstraction that provides generic functionality which developers can extend with custom code to create applications. It establishes a standard foundation for building and deploying soft ...
that allows
Java EE
Jakarta EE, formerly Java Platform, Enterprise Edition (Java EE) and Java 2 Platform, Enterprise Edition (J2EE), is a set of specifications, extending Java SE with specifications for enterprise features such as distributed computing and web serv ...
developers to map Java
class
Class, Classes, or The Class may refer to:
Common uses not otherwise categorized
* Class (biology), a taxonomic rank
* Class (knowledge representation), a collection of individuals or objects
* Class (philosophy), an analytical concept used d ...
es to
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
representations. JAXB provides two main features: the ability to
''marshal'' Java
object
Object may refer to:
General meanings
* Object (philosophy), a thing, being, or concept
** Object (abstract), an object which does not exist at any particular time or place
** Physical object, an identifiable collection of matter
* Goal, an a ...
s 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
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constrai ...
definitions to keep them synchronised with the Java definitions can be time-consuming and error-prone.
JAXB is one of the
APIs in the Jakarta EE platform (formerly Java EE), part of the
Java Web Services Development Pack (JWSDP), and one of the foundations for
WSIT. It was also part of the
Java SE platform (in version Java SE 6–10). As of Java SE 11, JAXB was removed. For details, se
JEP 320
JAXB 1.0 was released in 2003, having been developed under the
Java Community Process
The Java Community Process (JCP), established in 1998, is a formal mechanism that enables interested parties to develop standard technical specifications for Java technology. Becoming a member of the JCP requires solid knowledge of the Java program ...
as JSR 31. In 2006 JAXB 2.0 was released under JSR 222 and Maintenance Release 2 released in December 2009.
Reference implementation
In the software development process, a reference implementation (or, less frequently, sample implementation or model implementation) is a program that implements all requirements from a corresponding specification. The reference implementation ...
s for these specifications were available under the
CDDL open source license at
java.net.
Usage
The tool "" can be used to convert
XML Schema
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constrai ...
and other schema file types (as of Java 1.6,
RELAX NG
In computing, RELAX NG (REgular LAnguage for XML Next Generation) is a schema language for XML—a RELAX NG schema specifies a pattern for the structure and content of an XML document. A RELAX NG schema is itself an XML document but RELAX NG also ...
, XML
DTD, and
WSDL are supported experimentally) to class representations. Classes are marked up using
annotations from namespace, for example, and . XML list sequences are represented by attributes of type . Marshallers and Unmarshallers are created through an instance of JAXBContext.
In addition, JAXB includes a "" tool that can essentially perform the inverse of "", creating an XML Schema from a set of annotated classes.
Default data type bindings
The table below lists the mappings of
XML Schema
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constrai ...
(XSD) data types to Java data types in JAXB.
Versions
* Java SE 9: JAXB 2.3.0 (in module
java.xml.bind
; this module is marked as deprecated )
* Java SE 8: JAXB 2.2.8
* Java SE 7: JAXB 2.2.3 (JSR 222, maintenance release 2)
* Java SE 6: JAXB 2.0 (JSR 222)
See also
*
XML data binding
*
JiBX
*
XMLBeans – a similar and complementary technology to
JAXB from
Apache Software Foundation
The Apache Software Foundation ( ; ASF) is an American nonprofit corporation (classified as a 501(c)(3) organization in the United States) to support a number of open-source software projects. The ASF was formed from a group of developers of the ...
*
TopLink – an object to relational and object to
XML
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
mapper from
Oracle
An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination.
Descript ...
that supports JAXB 1.0
*
EclipseLink
EclipseLink is the open source Eclipse Persistence Services Project from the Eclipse Foundation. The software provides an extensible framework that allows Java developers to interact with various data services, including databases, web services, ...
MOXy –
open source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use and view the source code, design documents, or content of the product. The open source model is a decentrali ...
implementation of JAXB and object XML mapping services under the
Eclipse Foundation
The Eclipse Foundation AISBL is an independent, Europe-based not-for-profit organization that acts as a steward of the Eclipse open source software development community, with legal jurisdiction in the European Union. It is an organization supp ...
*
Liquid XML Studio – Commercial tool for XML data binding code generation
References
External links
* Reference Implementation on Project
GlassFish
GlassFish is an open-source Jakarta EE platform application server project started by Sun Microsystems, then sponsored by Oracle Corporation, and now living at the Eclipse Foundation and supported by OmniFish, Fujitsu and Payara. The support ...
Previous JAXB home page
* Original JAXB home page
A JAXB Tutorial by Wolfgang Laun
JSR 222(JAXB 2.0)
JSR 31(JAXB 1.0)
JAXB chapter of the Java EE 5 Tutorial
JAXB Wizard
JAXB Tutorials
Articles
JAXB 2.0 offers improved XML binding in JavaXML and Java technologies: Data binding, Part 2: Performance
{{DEFAULTSORT:Xml Binding Architecture
Java API for XML
Java specification requests