Wednesday, February 2, 2011

Creat a JAXB class library in NetBeans IDE









It's convenient to have a seperate JAXB class libray project when using JAXB in processing XML in Java application.

The below are the some simple steps to demonstrate how to create such a project in NetBeans IDE.

1. Create the project of Java class library
  • Start a new project by selecting New Project... from File menu
  • Choose project type as: Java Class Library
  • Give the name of the project and then click on Finish button

2. Create the JAXB binding
  • Right click on the new created project and choose New
  • Choose the file category as: XML and File Types as: JAXB Binding
  • Give the name of JAXB Binding
  • Select the schema file

3. Build the project


init:

deps-clean:

Deleting directory D:\WIS\commbiz-jaxb-lib\build

clean:

init:

deps-jar:

xjc-typedef-target:

jaxb-code-generation:

Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\addons\jaxb

Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache

Created dir: D:\WIS\commbiz-jaxb-lib\build\classes

Created dir: D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache\Commbiz

Compiling file:/D:/WIS/commbiz-jaxb-lib/xml-resources/jaxb/Commbiz/combiz_alterting_service.xsd

Writing output to D:\WIS\commbiz-jaxb-lib\build\generated\jaxbCache\Commbiz

Copying 54 files to D:\WIS\commbiz-jaxb-lib\build\generated\addons\jaxb

Compiling 54 source files to D:\WIS\commbiz-jaxb-lib\build\classes

compile:

Created dir: D:\WIS\commbiz-jaxb-lib\dist

Building jar: D:\WIS\commbiz-jaxb-lib\dist\commbiz-jaxb-lib.jar

jar:

BUILD SUCCESSFUL (total time: 2 seconds)

All generated JAXB classes based on the given schema file are in the .jar file.


No comments:

Post a Comment