user3343543
user3343543

Reputation: 141

How to create a JAXB project in IntelliJ IDEA 13?

I am learning JAXB. I need to know how should I create a simple java project for JAX-B in IntelliJ IDEA13. If anyone have idea, please update me and also update me with any plugin for IDEA

Thanks.

Upvotes: 2

Views: 6592

Answers (1)

bvdb
bvdb

Reputation: 24770

You don't need to do anything special when you create your project. Just a simple java project will do.

There are however some tricks that can help you. There are 2 built-in live templates for jaxb :

  1. typing mjo + hit tab-key: will generate the code for a marshaller.
  2. typing ujo + hit tab-key: will generate the code for an unmarshaller.

Intellij has built-in functionality for generating an xsd file for any xml file. Just right-click on any xsd file and you will see a button "Generate xsd schema from xml file".

JAXB also offers a tool (xjc.exe) to generate JAXB code stubs. There is a simple way to add this functionality to IntelliJ. I prefer to add a button for xsd to java source conversion, using the configuration in the "External Tools" menu.

Configuration of external tool

After this configuration, you can right-click on an xsd file and there will be a button "JAXB (XSD->JAVA)".

Note: According to some websites, there is also a dialog/wizard for generating jaxb stubs. However, I haven't found this wizard yet. Maybe it's only available in more recent IntelliJ versions (14+), maybe only in the commercial edition, or it may require some plugins. My solution works fine in IntelliJ 13.0.3 - Community Edition.

Upvotes: 7

Related Questions