title: What's the best way to persist data in a Java Desktop Application?
body: <p>I have a large tree of Java Objects in my Desktop Application and am trying to decide on the best way of persisting them as a file to the file system.</p>
  
  <p>Some thoughts I've had were:</p>
  
  <ul>
  <li><p><strong>Roll my own serializer using DataOutputStream</strong>:  This would give me the greatest control of what was in the file, but at the cost of micromanaging it.</p></li>
  <li><p><strong>Straight old Serialization using ObjectOutputStream and its various related classes</strong>: I'm not sold on it though since I find the data brittle.  Changing any object's structure breaks the serialized instances of it.  So I'm locked in to what seems to be a horrible versioning nightmare.</p></li>
  <li><p><strong>XML Serialization</strong>: It's not as brittle, but it's significantly slower that straight out serialization.  It can be transformed outside of my program.  </p></li>
  <li><p><strong>JavaDB</strong>: I'd considered this since I'm comfortable writing JDBC applications. The difference here is that the database instance would only persist while the file was being opened or saved.  It's not pretty but... it does lend itself to migrating to a central server architecture if the need arises later and it introduces the possibility of quering the datamodel in a simpler way.</p></li>
  </ul>
  
  <p>I'm curious to see what other people think. And I'm hoping that I've missed some obvious, and simpler approach than the ones above.</p>
  
  <hr>
  
  <p>Here are some more options culled from the answers below:</p>
  
  <ul>
  <li><strong>An Object Database</strong> - Has significantly less infrastructure than ORM approaches and performs faster than an XML approach. thanks aku</li>
  </ul>