BindGen toolBindGen is the tool used to generate a binding definition and matching schema definition from existing Java code. Running BindGenBindGen executes as a Java application, meaning it needs to be run directly from a
console window using the "java" command, or though some equivalent technique (such as
an Ant The BindGen application main class is Here's a sample of running BindGen on Unix/Linux systems from the examples/bindgen directory of the distribution (in a single line, shown split here only for formatting): java -cp ../../lib/jibx-tools.jar:bin org.jibx.binding.generator.BindGen org.jibx.starter1.Order On Windows, the corresponding command line is: java -cp ..\..\lib\jibx-tools.jar;bin org.jibx.binding.generator.BindGen org.jibx.starter.Order By default, BindGen output just goes to the current directory where it was executed. The generated root binding definition is named binding.xml, and the generated schema name is derived from the target namespace (which in turn is derived from the Java package name). Using build toolsYou can easily run BindGen from an Ant build, just as you would any other Java application. The build.xml in the examples/bindgen directory gives an example of this (which passes an optional source directory path parameter, in addition to a root class name), as shown below: <!-- set classpath for compiling and running application with JiBX --> <path id="classpath"> <fileset dir="${jibx-home}/lib" includes="*.jar"/> <pathelement location="bin"/> </path> ... <!-- generate default binding and schema --> <target name="bindgen"> <echo message="Running BindGen tool"/> <java classpathref="classpath" fork="true" failonerror="true" classname="org.jibx.binding.generator.BindGen"> <arg value="-s"/> <arg value="src"/> <arg value="org.jibx.starter1.Order"/> </java> </target> Most IDEs allow you to directly execute an Ant build target, so you can use the Ant approach to running BindGen from within your IDE. Command line parametersYou can pass a variety of command line parameters to BindGen, as listed below in alphabetical order:
You need to specify one or more class names as command line parameters to BindGen. Each class you name is used as a starting point for generating binding definitions. BindGen examines each class listed to find references to other classes, and then recursively examines the referenced classes, to find the complete set of classes necessary to represent your data. It then generates binding and schema definitions for all of these classes. The class names must be at the end of the command line, following any other command line parameters. You can pass global customizations to BindGen as command-line parameters,
by using |