I am trying to generate java classes from sample xsd using jdk 1.6, xjc command. But I don't want to use annotations i.e I don't want to generated java classes to contain annotations. How can I do it?
2 Answers
In JAXB (JSR-222) the only standard representation of the XML-binding metadata defined in the standard is JAXB annotations. Therefore an option to generate the classes without these annotations is of limited use.
I'm the EclipseLink JAXB (MOXy) lead an we do offer an XML (and JSON) representation of the JAXB metadata as an extension:
- XML - http://blog.bdoughan.com/2010/12/extending-jaxb-representing-annotations.html
- JSON - http://blog.bdoughan.com/2012/04/extending-jaxb-representing-metadata-as.html
If you are interested in having the ability to generate this metadata instead of annotations please request an enhancement in our bug database against the MOXy component:

- 337
- 3
- 15

- 147,609
- 23
- 300
- 400
This question has two parts:
- In the compile time you have to generate your code differently. You can write an XJC plugin to do this.
- In the runtime you have to use the JAXB implementation which works without annotations (see Blaise's answer on this part).
See this question on XJC extensibility:
You can write an XJC plugin which completely replaces the code generation. So I can imagine an XJC plugin which generates XML mappings for MOXy instead of annotations in classes. You can also do this with JAXB RI using an extra annotation reader, but it is much trickier as simply using MOXy.
Be warned, however, that writing advanced XJC plugins my be quite complex.