xjc command for JAXB applications
Use the JAXB tools to generate Java classes from an XML schema with the xjc schema compiler tool.
JAXB is an XML-to-Java binding technology that enables transformation between schema and Java objects and between XML instance documents and Java object instances. JAXB technology consists of a runtime API and accompanying tools that simplify access to XML documents. Use JAXB APIs and tools to establish mappings between Java classes and XML schema. An XML schema defines the data elements and structure of an XML document. JAXB technology provides a runtime environment to enable you to convert the XML documents to and from Java objects. Data stored in an XML document is accessible without the need to understand the XML data structure.
We can generate fully annotated Java classes from an XML schema file by using the JAXB schema compiler, xjc command-line tool. Use the xjc schema compiler tool to start with an XML schema definition (XSD) to create a set of Java Beansthat map to the elements and types defined in the XSD schema. Once the mapping between XML schema and Java classes exists, XML instance documents can be converted to and from Java objects through the use of the JAXB binding runtime API. The resulting annotated Java classes contains all the necessary information that the JAXB runtime requires to parse the XML for marshaling and unmarshaling. Use the resulting JAXB classes within JAX-WS applications or in the non-JAX-WS Java applications for processing XML data.
Supported configurations: The wsimport, wsgen, schemagen and xjc command-line tools are not supported on the z/OS platform. This functionality is provided by the assembly tools provided with WAS running on the z/OS platform. Read about these command-line tools for JAX-WS applications to learn more about these tools.
Best practice: WebSphere provides JAX-WS and JAXB tooling. The wsimport, wsgen, schemagen and xjc command-line tools are located in...
APP_ROOT\bin\Similar tooling is provided by the Java SE Development Kit (JDK) 6. For the most part, artifacts generated by both the tooling provided with WebSphere and the JDK are the same. In general, artifacts generated by the JDK tools are portable across compliant runtime environments. However, it is a best practice to use the WebSphere tools to achieve seamless integration within the WebSphere environment. bprac
Syntax
The command line syntax is:
(Windows)
APP_ROOT\bin\xjc.bat [options] <schema_file/URL/directory_or_jar> ...[-b<binding_information>] ...
[AIX] [HP-UX] [Linux] [Solaris]
APP_ROOT/bin/xjc.sh [options] <schema_file/URL/directory_or_jar> ...[-b<binding_information>] ...If a directory is specified, all schema files in the directory are compiled.
Parameters
The schema file/URL JAR file name or location of the directory is the only parameter that is required.
The following parameters are optional for the xjc command:
- -b <file_name or directory>
- External JAX-WS or JAXB binding files. We can specify multiple JAX-WS and JAXB binding files by using the -b option; however, each file must be specified with its own -b option. If a directory is specified, **/*.xjb is searched.
- -catalog <file_name>
- Catalog file to resolve external entity references. It supports the TR9401, XCatalog, and the OASIS XML Catalog formats.
- -classpath <path>
- Location of the class files.
- -d <directory>
- Specifies where to place the generated output files.
- -dtd
- Specifies to treat the input as XML Document Type Definition (DTD). This option is unsupported and experimental.
- -extension
- Whether to enable custom extensions for functionality not specified by the JAX-B specification. Use of the extensions can result in applications that are not portable or do not interoperate with other implementations.
- -help
- Display the help menu.
- -httpproxy <[user[:password]@]<proxyhost>:<proxyport>>
- Specifies an HTTP or HTTPs proxy.
- -httpproxyfile <file_name>
- Similar to the -httpproxy parameter, but takes the argument in a file to protect the password.
- -no-header
- Specifies to suppress the generation of a file header with a timestamp.
- -npa
- Specifies to suppress the generation of the **/package-info.java package level annotation.
- -nv
- Specifies to not perform a strict validation of the input schemas.
- -p <package_name>
- Target package.
- -quiet
- Specifies to suppress the output from the xjc tool.
- -relaxng
- Specifies to treat the input as REgular LAnguage for XML Next Generation (RELAX NG). This option is unsupported and experimental.
- -readOnly
- The generated files are in read-only mode.
- -relaxng-compact
- Specifies to treat the input as REgular LAnguage for XML Next Generation (RELAX NG) compact syntax. This option is unsupported and experimental.
- -target <version>
- Specifies to generate output to conform to the specified level of the JAX-WS specification. Specify 2.0 for the tool to generate compliant code for the JAX-B 2.0 specification. The default target version is 2.1 and generates compliant code for JAX-B 2.1.
- -verbose
- Specifies to output messages about what the compiler is doing.
- -version
- Prints the version information. If we specify this option, only the version information is output and typical command processing does not occur.
- -wsdl
- Specifies to treat the input as a WSDL file and compile schemas inside the WSDL. This option is unsupported and experimental.
- -xmlschema
- Specifies to treat the input as a World Wide Web Consortium (W3C) XML schema. This value is the default.
Related tasks
Use JAXB for XML data binding
Related
schemagen command for JAXB applications 
Related information
Web services specifications and APIs