JavaTM Architecture for XML Binding
Binding Compiler (xjc)

Specification Version: 1.0
Reference Implementation (RI) Version: 1.0.5

Main: Release Notes | XJC | Ant task | Sample Apps | Changelog
JAXB RI Extensions: Runtime Properties | XJC Customizations
JAXB RI Schema Languages: W3C XML Schema | RELAX NG | DTD
JAXB Community: Homepage | Developer interest list | FAQ

Launching xjc

The binding compiler can be launched using the appropriate xjc shell script in the bin directory for your platform. We also provide an Ant task to run the binding complier - see the instructions for using xjc with Ant.

For Solaris/Linux

  1. % export PATH=<your JWSDP1.6 installation directory>/jaxb/bin:$JWSDP_HOME/jwsdp-shared/bin:$PATH
  2. % $JAXB_HOME/bin/ -help

For WindowsNT/2000/XP

  1. > set PATH=<your JWSDP1.6 installation directory>\jaxb\bin;%JWSDP_HOME%\jwsdp-shared\bin;%PATH%
  2. > %JAXB_HOME%\bin\xjc.bat -help

Environment Variables


Usage: xjc [-options ...] <schemas>

  -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

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

Execute the jaxb-xjc.jar JAR File

If all else fails, you should be able to execute the jaxb-xjc.jar file:

For Solaris/Linux:
% java -jar <your JWSDP1.6 installation directory>/jaxb/lib/jaxb-xjc.jar -help
For Windows:
> java -jar <your JWSDP1.6 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.xjb
xjc schema1.xsd schema2.xsd schema3.xsd -b bindings1.xjb -b bindings2.xjb -b bindings3.xjb
In addition, the ordering of the schema files and binding files on the command line does not matter.

-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.
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.6/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.6/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.

Compiler Restrictions

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.

Generated Resource Files

The xjc binding compiler produces a set of packages containing a combination of Java source files and resource files. The following list of resource files generated by xjc must be kept with the compiled source code and made available on the runtime classpath of your client applications:

A pair of these resource files is contained in each of the packages containing schema-derived Java content interfaces. Make sure to copy these resource files into the appropriate directories to maintain the proper relationship with the generated Java source files. The following snippet of Ant code illustrates how this can be achieved:

<path id="classpath">

<target name="compile">
  <!-- compile all xsd files in the src dir and put the output in the build dir -->
  <xjc target="build">
    <schema  dir="src" includes="*.xsd"/>
    <binding dir="src" includes="*.xjb"/>

  <!-- compile all java files in the src dir and put the output in the build dir -->
  <javac srcdir="src" destdir="build" debug="on">
    <classpath refid="classpath" />

  <!-- copy all of the generated resource files from the src dir into the build dir -->
  <copy toDir="build">
    <fileset dir="src">
      <include name="**/"/>
      <include name="**/bgm.ser"/>

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.proxyPort=80 -jar $JAXB_HOME/lib/jaxb-xjc.jar -help
For Windows:
> java -Dhttp.proxyPort=80 -jar %JAXB_HOME%\lib\jaxb-xjc.jar -help

$Revision: 1.2 $
$Date: 2004/10/07 21:54:02 $