XSD to JAR using JAXB Binding Compiler

  • Post author:
  • Post category:Tools

Here are the contents of our batch file that converts a .xsd file into a .jar file. It uses xjc, so you can use JAXB to  convert objects to XML and vice versa.

@echo off

set INPUT_XSD=..\sample.xsd
set OUTPUT_JAR=sample.jar

mkdir ~dir
cd ~dir

xjc.exe %INPUT_XSD%

dir /s /B *.java > ~list
javac @~list
del ~list

jar cf ../%OUTPUT_JAR% *

cd ..

rmdir ~dir /s /q