Marshalling means producing a stream of byte which contain enough information to be able to re-build the object. This make no impact on the original object, because it is a read-only operation.
JAXB stand for Java Architecture for XML Binding. Jaxb allows us to map Java classes to XML representations. JAXB can be used Java to marshal java object into xml or/and to unmarshal XML back into Java objects.
I used these 2 jar for this example. You can download latest version of jar and add it to your class path.
Here is BookCatalog.java which we are going to marshalled into xml using Jaxb apis.
Source code of MarshalingMain.java is given below.