1

Possible Duplicate:
What is the difference between Serialization and Marshalling?

what is marshalling in java and what is the difference between marshalling and serialization?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
Mukesh
  • 11
  • 2

1 Answers1

1

There are many excellent posts on Stackoverflow on this, but if you want a simple answer here it is:

They're the same, and the terms are used interchangeably. In the Java world, both are actually used.

For JAXB (converting objects to XML), the term marshalling is used. e.g.,

       JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
       Unmarshaller u = jc.createUnmarshaller();
       FooObject obj = (FooObject)u.unmarshal( new File( "foo.xml" ) );
       Marshaller m = jc.createMarshaller();

For converting Java objects to bytes, the term serializing is used. e.g.,

import java.io.Serializable;
public class Person implements Serializable
{
   private String name;

   public Person(String name)
   {
      this.name = name;
   }
   public String getName()
   {
      return name;
   }
}

So it's mostly semantics.

The Alchemist
  • 3,397
  • 21
  • 22