Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a jar file from xsd

Tags:

java

jar

xsd

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?

like image 824
Shreyos Adikari Avatar asked Dec 08 '22 20:12

Shreyos Adikari


1 Answers

You can use the following steps if you are not using mavne to generate jar-

  1. Copy your xsd to a folder.- eg Test.xsd

  2. 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.

  1. From the command prompt use -

    javac generated/*

    This will create classes files of all the java files generated.

  2. Lastly, from the command prompt, use

    jar cvf test.jar generated/*

    This will create the jar with all the classes.

like image 120
Saurav Avatar answered Dec 27 '22 15:12

Saurav