XJC -p Option for Class Package Name


How to specify the package name for the generated Java classes with XJC (XML to Java Compiler)? I don't like the default package name "generated".

✍: FYIcenter.com


I don't like the default package name "generated" of the output Java classes given by XJC (XML to Java Compiler), you can change it by using the "xjc -p" option as shown below:

\fyicenter>mkdir src

\fyicenter>\local\jdk-1.8.0\bin\xjc -p com.fyicenter.demo User.xsd -d src
parsing a schema...
compiling a schema...

Remember that:

  • "-p com.fyicenter.demo" specifies the package name for all generated Java classes.
  • "-d src" specifies the folder where the generated source code should go. It must be provided after the XML schema file name, User.xsd.


Examples for JAXB (Java Architecture for XML Binding)

⇒⇒FAQ for jaxb-*.jar - Java Architecture for XML Binding

2018-05-08, 0👍, 0💬