xjc command for JAXB applications
Use the Java™ Architecture for XML Binding (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. You can 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 your XML documents to and from Java objects. Data stored in an XML document is accessible without the need to understand the XML data structure.
You 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 JavaBeans that 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. You can use the resulting JAXB classes within Java API for XML Web Services (JAX-WS) applications or in your non-JAX-WS Java applications for processing XML data.
支援的配置: z/OS® 平台不支援 wsimport、wsgen、schemagen 和 xjc 指令行工具。
這項功能是由隨執行於 z/OS 平台的 WebSphere® Application Server 提供的組合工具所提供。請閱讀 JAX-WS 應用程式的這些指令行工具以進一步瞭解這些工具。sptcfg
最佳作法: WebSphere Application Server 提供 Java API for XML-Based Web Services (JAX-WS) 和 Java Architecture for XML Binding (JAXB) 工具。
wsimport、wsgen、schemagen 和 xjc 指令行工具位於 WebSphere Application Server 傳統版的 app_server_root\bin\ 目錄中。
xjc 和 schemagen 指令位於 Liberty 設定檔的 app_server_root\jaxb\bin\ 目錄中。
在某些情況下,WebSphere Application Server 和 JDK 提供的工具所產生的構件,支援相同層次的規格。一般而言,JDK 工具所產生的構件可以在其他標準執行時期環境之間轉移。
不過,最好的作法是利用這個產品所提供的工具來實現在 WebSphere Application Server 環境內的緊密整合,以及使用可能只在 WebSphere Application Server 環境內受到支援的特性。
如果要利用 JAX-WS 和 JAXB 2.2 版工具,請使用在 app_server_root\bin\ 目錄內之應用程式伺服器所提供的工具。bpracIn addition to using the xjc tool from the command line, you can invoke this JAXB tool from within the Ant build environments. Use the com.sun.tools.xjc.XJCTask Ant task from within the Ant build environment to invoke the xjc schema compiler tool. To function properly, this Ant task requires that you invoke Ant using the ws_ant script.
避免困難: If you are using the xjc Ant
task, you must use the destdir parameter to specify
the destination directory instead of the target option.
Specifying the target option when using the xjc Ant
task causes an error. gotchaSyntax
The command-line syntax is:
![[Windows]](../images/windows.gif)
app_server_root\bin\xjc.bat [options] <schema_file/URL/directory_or_jar> ...[-b<binding_information>] ...
![[AIX]](../images/aixlogo.gif)
![[HP-UX]](../images/hpux.gif)
![[Linux]](../images/linux.gif)
![[Solaris]](../images/solaris.gif)
app_server_root/bin/xjc.sh [options] <schema_file/URL/directory_or_jar> ...[-b<binding_information>] ...
![[IBM i]](../images/iseries.gif)
app_server_root/bin/xjc [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>
- Specifies the external JAX-WS or JAXB binding files. You 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>
- Specifies the catalog file to resolve external entity references. It supports the TR9401, XCatalog, and the OASIS XML Catalog formats.
- -classpath <path>
- Specifies the 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
- Specifies whether to enable custom extensions for functionality not specified by the JAXB specification. Use of the extensions can result in applications that are not portable or do not interoperate with other implementations.
- -help
- Displays the help menu.
- -httpproxy <[user[:password]@]<proxyhost>:<proxyport>>
- Specifies an HTTP or HTTPs proxy.
- -httpproxyfile <file_name>
- This parameter is 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>
- Specifies a 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
- Specifies that 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 or 2.1 for the tool to generate compliant code for the JAXB 2.0 or JAX-WS 2.1 specification respectively. Specify 2.1 for the tool to generate compliant code for the JAXB 2.1 specification. The default target version is 2.2 and generates compliant code for the JAXB 2.2 specification.
- The target option is required for Liberty profile.
- -verbose
- Specifies to output messages about what the compiler is doing.
- -version
- Prints the version information. If you specify this option, only the version information is output and typical command processing does not occur.
- -wsdl
- Specifies to treat the input as a Web Services Description Language (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.
參照主題