How to create a jar
file containing class files generated from a given xsd
file?
Do we need to create all the java files from xsd
and then need to compile and create a jar
?
Or, other solutions are there.
Can anyone please explain the process?
You can use the following steps if you are not using mavne to generate jar-
Copy your xsd to a folder.- eg Test.xsd
From the command prompt go to the folder and use the command-
xjc Test.xsd
or u can use xjc -p --package name--
xjc -p test Test.xsd
This will create all your java files from the xsd, in a folder called generated(default) or test inside your working folder.
From the command prompt use -
javac generated/*
This will create classes files of all the java files generated.
Lastly, from the command prompt, use
jar cvf test.jar generated/*
This will create the jar with all the classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With