Showing posts from July, 2013

JAXB Bigdecimal/BigInteger adapter

JAXB BigDecimal / BigInteger apapters Jaxb NumberFormatException XML attributes represents null values with empty string. During unmarshalling an XML with empty value for a BigDecimal/BigInteger JAXB throws NumberFormatException. For the case of BigDecimal it will be NumberFormatException at java.math.BigDecimal.<init> and for BigInteger it can be NumberFormatException: Zero length BigInteger at java.math.BigInteger.<init> exception. To overcome this problem, Jaxb provides a feature called TypeAdapters. Using TypeAdapters we can specify how to marshall/unmarshall a particular object or complex xml type when some of its fields are not proper. For example we can instruct JAXB if BigDecimal is empty treat it as 0, don't report an exception. BigDecimal Adapter   Below is the sample BigDecimal Adapter which advices marshall and unmarshall in the event of null values. /* * * * Adapter for java.math.BigDecimal objects * */ pac

Ubuntu instalation and un-install on windows 7

Installation and un-installing ubuntu from windows   Installation   To install Ubuntu 1. Using Ubuntu desktop ISO 2. Wubi installer   Wubi installer This is the easiest and simpler way to install Ubuntu. Download Ubuntu windows installer from This just like any other windows software installer, so you can install and uninstall Ubuntu at any time.   Ubuntu desktop ISO Download the Ubuntu desktop ISO here Select 32 bit or 64 bit based on your computer. You have to create an USB/CD bootable disk with Ubuntu to install it on your computer. You can do this with different utilities. Pendrive Linux at and installation instructions linuxlive USB creator here   and installation instructions

XML to Java code generation

 XML to Java code generation using CASTOR and JAXB This tutorial explains the code generation from xml to java by using Castor and JAXB in brief.  Procedure   Generate XSD from XML using CASTOR   Generate Java objects from XSD JAXB.  Each of the steps in detail below. XSD Generation    There are lot of tools available to generate XSD from XML including a few online tools. CASTOR is one such tool can be used to generate XSD form XML. Castor is the Open Source data binding framework for Java. Mainly it consists of two features Castor XML and Castor JDO. Download and install castor from The Castor JARs, docs, DTDs, command line tools, and examples can be downloaded from     XML Instance to Schema Follow the below steps to generate Schema from XML. Open command prompt Java_home should point to java install directory Set