title: readObject throwing ClassNotFoundException when deserializing objects from independent class
body: <p>My question is about unserializing a file that is created using one class "Character" and a GUI form "NewChar".</p>
  
  <p>I'm relatively new to Java and trying to create a DnD style character generator.  I have three classes that I'm working with currently - Character (the java class that houses the actual stats like name, gender, class, str, dex, etc.) that includes a constructor; a GUI form (NewChar, created using NetBeans and Swing) that allows the user to select the stats as defined in the Character class and customize them as desired; and the CharMain GUI page that should (eventually) show the user their character and allow them to level up, choose a weapon, etc.  </p>
  
  <p>As of right now, I can successfully serialize the data by instantiating the class Character within the NewChar GUI frame (as far as I can tell).  I am as of yet unable to load the serialized file from my CharMain GUI page.  Primarily, the issue seems to be the ClassNotFoundException when I try to readObject(); on any of the strings I've tried to serialize.  Secondarily, I continue to receive the EOF exception although I suspect that's because the amount of items serialized and then unserialized doesn't match since the readObject(); isn't working.  I've googled and searched StackOverFlow and found a few responses to similar questions (ex: <a href="https://stackoverflow.com/questions/2916107/readobject-method-throws-classnotfoundexception">readobject method throws ClassNotFoundException</a> or <a href="https://stackoverflow.com/questions/5217902/java-mysterious-eof-exception-with-readobject">Java Mysterious EOF exception with readObject</a>) but can't make heads or tails of the responses given with respect to my situation.  </p>
  
  <p>I have tried to copy and paste my Character class into the two GUI forms but that doesn't seem to have helped.  I've also tried serializing only the instance of the class Character (instance called createdChar) but that didn't seem to help either.  </p>
  
  <p>I know that the objects I'm trying to deserialize needs to match the objects that have been serialized (i.e. package, class name, etc.) but as far as I can tell they do.  I'm probably being super-blind and/or stupid-oblivious but my in-house fellow coder can't seem to figure it out either.  At this point I'm thinking about writing the info to a text file and reading that back instead of utilizing the ObjectOutputStream and ObjectInputStream but would still really like to know why this doesn't work.  Please help!</p>
  
  <p>Here is the code to serialize (and then de-serialize) the data:</p>
  
  <pre><code>private void viewCharActionPerformed(java.awt.event.ActionEvent evt) {                                         
      // TODO add your handling code here:
      String fileName = String.valueOf(createdChar.charName);
      try {
          FileOutputStream charSave = new FileOutputStream("/C:\\javaSaves\\newChar.sav");
          ObjectOutputStream out = new ObjectOutputStream(charSave);
  
          out.writeObject(createdChar.str);
          out.writeObject(createdChar.dex);
          out.writeObject(createdChar.con);
          out.writeObject(createdChar.intel);
          out.writeObject(createdChar.wis);
          out.writeObject(createdChar.charisma);
          out.writeObject(createdChar.strMod);
          out.writeObject(createdChar.dexMod);
          out.writeObject(createdChar.conMod);
          out.writeObject(createdChar.intelMod);
          out.writeObject(createdChar.wisMod);
          out.writeObject(createdChar.charisMod);
          out.writeObject(createdChar.baseAttack);
          out.writeObject(createdChar.reflexSave);
          out.writeObject(createdChar.willSave);
          out.writeObject(createdChar.fortSave);
          out.writeObject(createdChar.hp);
          out.writeObject(createdChar.lvl);
          out.writeObject(createdChar.speed);
          out.writeObject(createdChar.armorClass);
          out.writeObject(createdChar.size);
          out.writeObject(createdChar.charName);
          out.writeObject(createdChar.charRace);
          out.writeObject(createdChar.charClass);
          out.writeObject(createdChar.gender);
  
          out.close();
          charSave.close();
          System.out.printf("Serialized data is saved on C:\\javaSaves\\newChar.sav");
     }
      catch (IOException i) {
          i.printStackTrace();
      }
  
          java.awt.EventQueue.invokeLater(new Runnable() {
              public void run() {
                  new charMain().setVisible(true);
              }
          });
  
          closeFrame();
  }  
  
  public void loadCharacterFromFile(){
      try {
          FileInputStream saveFile = new FileInputStream("/C:\\javaSaves\\newChar.sav");
          ObjectInputStream save = new ObjectInputStream(saveFile);
              createdChar.str = save.readInt();
              createdChar.dex = save.readInt();
              createdChar.con = save.readInt();
              createdChar.intel = save.readInt();
              createdChar.wis = save.readInt();
              createdChar.charisma = save.readInt();
              createdChar.strMod = save.readInt();
              createdChar.dexMod = save.readInt();
              createdChar.conMod = save.readInt();
              createdChar.intelMod = save.readInt();
              createdChar.wisMod = save.readInt();
              createdChar.charisMod = save.readInt();
              createdChar.baseAttack = save.readInt();
              createdChar.reflexSave = save.readInt();
              createdChar.willSave = save.readInt();
              createdChar.fortSave = save.readInt();
              createdChar.hp = save.readInt();
              createdChar.lvl = save.readInt();
              createdChar.speed = save.readInt();
              createdChar.armorClass = save.readInt();
              createdChar.size = (String) save.readObject();
              createdChar.charName = (String) save.readObject();    
              createdChar.charRace = (String) save.readObject();
              createdChar.charClass = (String) save.readObject();
              createdChar.gender = (String) save.readObject();
  
          save.close();
          saveFile.close();
      }
      catch (IOException i) {
          i.printStackTrace();
      }
  }
  </code></pre>