title: Reading an unkown serialized object in Java
body: <p>I have a server that crashed (Minecraft if you want to know), and some precious data were saved in a serialized object file. I did not succeed reading it with Java's ObjectInputStream. This is piece of code I found online edited a little. When I read the object, it throws an ClassNotFoundException.</p>
  
  <pre><code>//Part of it
  ObjectInputStream objStream = new ObjectInputStream(new FileInputStream(f));
  Object obj = objStream.readObject();
  System.out.println("The Object : "+  obj);
  objStream.close();
  System.out.println("Deserializing Operation Completly Successfully.");
  </code></pre>
  
  <p>The problem is I don't know it's content at all. How do I know what are the fields and the methods are contained in this object?</p>
  
  <pre><code>java.lang.ClassNotFoundException: net.****.****.****.**** //CENSORED
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:249)
  at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:602)
  at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1589)
  at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1494)
  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1748)
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1327)
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
  at java.util.ArrayList.readObject(ArrayList.java:593)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:979)
  at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
  at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
  at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1327)
  at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
  at main.ReadFile.main(ReadFile.java:28)
  </code></pre>
  
  <p><strong>Edit:</strong> I have decompiled it, and added all of it's packages to my src. Successfully read the object. But this DOES NOT ANSWER the question, the question remains;"how to read an unkown serialized object in Java.".</p>