title: Java - ImageIcon Serialization Trouble (Last Part of Game)
body: <p>I've been working on my game pretty much non stop since 11am this morning. And I'm just about done.</p>
  
  <p><strong>But I get an error whenever I try to serialize and deserialize my data...</strong></p>
  
  <p>There's is a "game running" class that extends JFrame. And that holds other classes that are serializable. Now, when I try to serialize those objects to a file (or read them back into the program) I get an error.</p>
  
  <p>Here's the gist of it:</p>
  
  <pre><code>java.io.IOException: failed to load image contents
  at javax.swing.ImageIcon.writeObject(ImageIcon.java:418)
  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.invokeWriteObject(ObjectStreamClass.java:945)
  at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
  at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
  at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
  at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
  at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
  at javax.swing.JLabel.writeObject(JLabel.java:890)
  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.invokeWriteObject(ObjectStreamClass.java:945)
  at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
  at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
  at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
  at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
  at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
  </code></pre>
  
  <p>** Is it possible to serialize ImageIcons? (My teacher told me yes, which is why I used them.**</p>
  
  <p>If it matters, this is how I declared/initialized the imageicons in my serializable class:</p>
  
  <pre><code>private final Image heroIcona = new ImageIcon("heroIcon.png").getImage();
  </code></pre>