Sunday, September 19, 2010

Generating Java POJO from XSD schema - JAXB and CASTOR

It is a contribution from Parthiban Rajasekaran

Generate Java Files using JAXB
1. Download latest JAXB Binary from https://jaxb.dev.java.net [latest as of now can be downloaded from https://jaxb.dev.java.net/2.2/JAXB2_20091104.jar] and execute this jar to get the JAXB package
2. Create JAXB_HOME with the jaxb extracted location, for example D:\Personal\Downloaded\Sun API\JAXB\jaxb-ri-20091104
3. Append %JAXB_HOME%\bin in the path system variable
4. Execute xjc command from the dtd or xsd location to generate java files
a. To create java from dtd – xjc -d -p -dtd
b. To create java from xsd – xjc -d -p

Hint: Convert DTD to XML - http://www.hitsw.com/xml_utilites/

Generate Java Files from XSD using Castor

set classpath=castor-1.3-codegen.jar;castor-1.3-xml.jar;castor-1.3-xml-schema.jar;castor-1.3-core.jar;commons-logging-1.1.1.jar;%CLASSPATH%;

java org.exolab.castor.builder.SourceGeneratorMain -i message.xsd -package com.bt.hqn.creditclient.buynet.integration.cbean






3 comments:

  1. jaxb download links not working

    ReplyDelete
  2. Hi, i think that i saw you visited my weblog so i came to “return
    the favor”.I'm trying to find things to improve my website!I suppose its ok to use some

    of your ideas!!
    Look into my blog post Alhaurin el Grande Property

    ReplyDelete
  3. Good blog! I truly love how it is easy on my eyes and the
    data are well written.

    I am wondering how I could be notified when a new post has been
    made. I've subscribed

    to your feed which must do the trick! Have a nice day!
    Also visit my blog : http://herronsites.com/wiki/index.php?title=dolores_spain

    ReplyDelete