JavaTM Architecture for XML Binding
Specification Version: 2.0
Binding Compiler (xjc)
Reference Implementation (RI) Version: 2.0 EA
JAXB 2.0: Release Notes | XJC | XJCTask | SchemaGen | schemagenTask | Sample Apps | Changelog
JAXB 1.0.x: Release Notes | Changelog
JAXB RI Extensions: Runtime Properties | XJC Customizations | Develop Plugins
JAXB RI Schema Languages: W3C XML Schema | RELAX NG | DTD
JAXB Community: Java.net Homepage | Developer interest list | FAQ
The binding compiler can be launched using the appropriate
xjc shell script in the
for your platform. We also provide an Ant task to run the binding
complier - see the instructions for
using xjc with Ant.
- % export PATH=<your JWSDP1.4 installation directory>/jaxb/bin:$JWSDP_HOME/jwsdp-shared/bin:$PATH
- % $JAXB_HOME/bin/xjc.sh -help
- > set PATH=<your JWSDP1.4 installation directory>\jaxb\bin;%JWSDP_HOME%\jwsdp-shared\bin;%PATH%
- > %JAXB_HOME%\bin\xjc.bat -help
- XJC_OPTS - command-line arguments that should be passed to the JVM. For example, you can define system properties or set the maximum Java heap size here. If you are using the xjc ant task, you would specify these options via the ANT_OPTS evironment variable.
OutputUsage: xjc [-options ...] <schemas> Options: -nv : do not perform strict validation of the input schema(s) -extension : allow vendor extensions - do not strictly follow the Compatibility Rules and App E.2 from the JAXB Spec -b <file> : specify external bindings files (each <file> must have its own -b) -d <dir> : generated files will go into this directory -p <pkg> : specifies the target package -host <proxyHost> : set http.proxyHost property to <proxyHost> -port <proxyPort> : set http.proxyPort property to <proxyPort> -classpath <arg> : specify where to find user class files -catalog <file> : specify catalog files to resolve external entity references support TR9401, XCatalog, and OASIS XML Catalog format -readOnly : generated files will be in read-only mode -use-runtime <pkg> : suppress the generation of the impl.runtime package and simply refer to another existing runtime in the specified package -xmlschema : treat input as W3C XML Schema (default) -relaxng : treat input as RELAX NG (experimental,unsupported) -dtd : treat input as XML DTD (experimental,unsupported) -quiet : suppress compiler output -help : display this help message -version : display version information -source [1.0|2.0] : specify which version of the schema compiler to use. Defaults to "2.0"
Non-standard Commandline Options
These options are non-standard and may change without notice.-Xlocator : enable source location support for generated code -Xsync-methods : generate accessor methods with the 'synchronized' keyword
If all else fails, you should be able to execute the
- For Solaris/Linux:
- % java -jar <your JWSDP1.4 installation directory>/jaxb/lib/jaxb-xjc.jar -help
- For Windows:
- > java -jar <your JWSDP1.4 installation directory>\jaxb\lib\jaxb-xjc.jar -help
Summary of Command Line Options
- By default, the XJC binding compiler performs strict validation of the source schema before processing it. Use this option to disable strict schema validation. This does not mean that the binding compiler will not perform any validation, it simply means that it will perform less-strict validation.
- By default, the XJC binding compiler strictly enforces the rules outlined in the Compatibility chapter of the JAXB Specification. Appendix E.2 defines a set of W3C XML Schema features that are not completely supported by JAXB v1.0. In some cases, you may be allowed to use them in the "-extension" mode enabled by this switch. In the default (strict) mode, you are also limited to using only the binding customizations defined in the specification. By using the "-extension" switch, you will be allowed to use the JAXB Vendor Extensions.
- -b <file>
- Specify one or more external binding files to process. (Each binding file must have it's own "-b" switch.) The syntax of the external binding files is extremely flexible. You may have a single binding file that contains customizations for multiple schemas or you can break the customizations into multiple bindings files:
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings123.xjbIn addition, the ordering of the schema files and binding files on the command line does not matter.
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings1.xjb -b bindings2.xjb -b bindings3.xjb
- -d <dir>
- By default, the XJC binding compiler will generate the Java content classes in the current directory. Use this option to specify an alternate output directory. The output directory must already exist, the XJC binding compiler will not create it for you.
- -p <pkg>
- Specifying a target package via this command-line option overrides any binding customization for package name and the default package name algorithm defined in the specification.
- -host <proxyHost>
- Specify a value for the http.proxyHost networking property.
- -port <proxyPort>
- Specify a value for the http.proxyPort networking property.
- -classpath <arg>
- Specify where to find client application class files used by the <jxb:javaType> and <xjc:superClass> customizations.
- -catalog <file>
- Specify catalog files to resolve external entity references. Supports TR9401, XCatalog, and OASIS XML Catalog format. Please read the XML Entity and URI Resolvers document or the catalog-resolver sample application.
- By default, the XJC binding compiler does not write-protect the Java source files it generates. Use this option to force the XJC binding compiler to mark the generated Java sources read-only.
- -use-runtime <pkg>
- suppress the generation of the impl.runtime package and simply refer to another existing runtime in the specified package. This option is useful when you are compiling multiple independent schemas. Because the generated impl.runtime packages are identical except for their package declarations, you can reduce the size of your generated codebase by telling the compiler to reuse an existing impl.runtime package.
When using this switch, be careful to specify a version of the runtime package compatible with your version of JAXB. Otherwise, you may encounter javac failures when attempting to compile your generated classes. For example, you should not specify a set of runtime classes generated from an older version of the binding compiler with the current binding compiler.
- treat input schemas as W3C XML Schema (default). If you do not specify this switch, your input schemas will be treated as W3C XML Schema.
- Treat input schemas as RELAX NG (experimental, unsupported). Support for RELAX NG schemas is provided as a JAXB Vendor Extension.
- Treat input schemas as XML DTD (experimental, unsupported). Support for RELAX NG schemas is provided as a JAXB Vendor Extension.
- Suppress compiler output, such as progress information and warnings..
- Display a brief summary of the compiler switches.
- Display the compiler version information.
- -source [1.0|2.0]
- Specify which version of the schema compiler to use. The generated source code will follow the binding rules specified by either JAXB 1.0 Specification or JAXB 2.0 Specification. Defaults to 2.0
- Specify one or more schema files to compile.
Summary of Non-Standard Command Line Options
- This feature is only available when you include jwsdp-1.4/jaxb/samples/locator-support/jaxb-locator-support.jar on your classpath. Please refer to the readme.txt file located with the sample app for more detail.
- This feature is only available when you include jwsdp-1.4/jaxb/samples/synchronized-methods/jaxb-synchronized-methods.jar on your classpath. Please refer to the readme.txt file located with the sample app for more detail.
In general, it is safest to compile all related schemas as a single unit with the same binding compiler switches.
Please keep the following list of restrictions in mind when running xjc. Most of these issues only apply when compiling multiple schemas with multiple invocations of xjc.
- To compile multiple schemas at the same time, keep the following
precedence rules for the target Java package name in mind:
- The "-p" command line option takes the highest precedence.
- <jaxb:package> customization
- If targetNamespace is declared, apply targetNamespace -> Java package name algorithm defined in the specification.
- If no targetNamespace is declared, use a hardcoded package named "generated".
- It is not legal to have more than one <jaxb:schemaBindings> per namespace, so it is impossible to have two schemas in the same target namespace compiled into different Java packages.
- All schemas being compiled into the same Java package must be submitted to the XJC binding compiler at the same time - they cannot be compiled independently and work as expected.
- Element substitution groups spread across multiple schema files must be compiled at the same time.
Specifying Proxy Settings
The XJC binding compiler has support for the http.proxyHost and http.proxyPort networking properties. Specify the "-host" and "-port " command-line options on the xjc scripts that are located in the bin directory.
If you are launching the XJC binding compiler manually, you can specify the values of these properties on the Java command line as follows:
- For Solaris/Linux:
- % java -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=80 -jar $JAXB_HOME/lib/jaxb-xjc.jar -help
- For Windows:
- > java -Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=80 -jar %JAXB_HOME%\lib\jaxb-xjc.jar -help
$Revision: 1.29 $
$Date: 2005/03/29 16:38:17 $