I'm trying to automate the generation of Java classes from XML DTD using xjc. The generated Java classes must be serializable. The articles that help with that add a pointer to a bindings file that uses the schema at http://java.sun.com/xml/ns/jaxb for the JAXB namespace, but that URL doesn't work anymore.
The URL http://java.sun.com/xml/ns/jaxb redirects to http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jaxb/index.html which in turn says that http://java.sun.com/xml/ns/jaxb is the latest URL but links to http://www.oracle.com/xml/ns/jaxb/ that also redirects to http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jaxb/index.html.
A bit confusing.
I've found tutorials at Oracle updated in 2014 that still use that URL, and I didn't find any other. Does anyone have a more up to date info?
JAXB stands for Java Architecture for XML Binding.
xjb extension to resolve any conflicts in the WSDL or schema. For example if two elements have the same name and you want to distinguish between them you can rename one by specifying it the bindings file.
7.1. The JAXB-2 Maven plugin uses the JDK-supplied tool XJC, a JAXB Binding compiler tool that generates Java classes from XSD (XML Schema Definition). By default, this plugin locates XSD files in src/main/xsd.
Open a command prompt. Run the JAXB schema compiler, xjc command from the directory where the schema file is located. The xjc schema compiler tool is located in the app_server_root \bin\ directory. Use the generated JAXB objects within a Java application to manipulate XML content through the generated JAXB classes.
This works for me:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:jaxb='http://java.sun.com/xml/ns/jaxb' version='2.1'
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/jaxb/bindingschema_2_0.xsd">
</jaxb:bindings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With