title: ClassNotFoundException with readObject() method
body: <p>I'm trying to read objects from a file in the Internet. I have been given the object class, which is this:</p>
  
  <pre><code>import java.io.Serializable;
  
  
  public class Sulearvuti extends Arvuti implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      //isendiväli
      private int aku;
  
  
      //konstruktor
      public Sulearvuti(String tootja, String mudel, String lisainfo,
              int järjekorraNumber, int raskusaste, boolean kiirtellimus, int aku)
              throws ValeRaskusAsteErind {
          super(tootja, mudel, lisainfo, järjekorraNumber, raskusaste,
                  kiirtellimus);
          this.aku = aku;
      }
  
      // meetod toString, kasutama ülemklassi meetodit
      public String toString() {
          return "Sülearvuti [aku=" + aku + ", " + super.toString() + "]";
      }
  
      // meetodi ülekatmine
      double parandamiseAeg(){
          return this.getRaskusaste()*2;
      }
  
  
  }
  </code></pre>
  
  <p>Now when I'm trying to read the objects (Sulearvuti), I get ClassNotFoundException. This is the piece of code :</p>
  
  <pre><code>ObjectInputStream ois = 
      new ObjectInputStream (
          new URL("http://www.ut.ee/~marinai/sulearvutid.dat")
          .openConnection()
          .getInputStream());
  
  int arv=ois.readInt();
  Sulearvuti sülearvuti=(Sulearvuti)ois.readObject();
  </code></pre>
  
  <p>There's no problem with the Integer, but it won't recognize the class. I've been desperate for the past hour or so...</p>
  
  <p>Also here's the code for the superclass "Arvuti":</p>
  
  <pre><code>import java.io.Serializable;
  
  public class Arvuti implements  Serializable, Comparable&lt;Arvuti&gt; {
  
  private String tootja;
  private String mudel;
  private String lisainfo;
  private int jrnumber;
  private int vea_raskusaste;
  private boolean kiirtellimus;
  String getTootja() {
      return tootja;
  }
  String getMudel() {
      return mudel;
  }
  String getLisainfo() {
      return lisainfo;
  }
  int getJrnumber() {
      return jrnumber;
  }
  int getVea_raskusaste() {
      return vea_raskusaste;
  }
  boolean isKiirtellimus() {
      return kiirtellimus;
  }
  void setTootja(String tootja) {
      this.tootja = tootja;
  }
  void setMudel(String mudel) {
      this.mudel = mudel;
  }
  void setLisainfo(String lisainfo)throws WindowsXPErind {
      this.lisainfo = lisainfo;
      if(lisainfo.contains("WindowsXP"))throw new WindowsXPErind();
  
  }
  void setJrnumber(int jrnumber) {
      this.jrnumber = jrnumber;
  }
  void setVea_raskusaste(int vea_raskusaste)throws ValeRaskusAsteErind {
      if(vea_raskusaste&lt;1 || vea_raskusaste&gt;10) throw new ValeRaskusAsteErind();
      this.vea_raskusaste = vea_raskusaste;
  }
  void setKiirtellimus(boolean kiirtellimus) {
      this.kiirtellimus = kiirtellimus;
  }
  Arvuti(String tootja, String mudel, String lisainfo, int jrnumber,
          int vea_raskusaste, boolean kiirtellimus)throws ValeRaskusAsteErind {
      try{
      setTootja( tootja);
      setMudel(mudel);    
      setJrnumber(jrnumber);
      setVea_raskusaste(vea_raskusaste);
      setKiirtellimus(kiirtellimus);
      setLisainfo(lisainfo);
      }
      catch (WindowsXPErind e){
          System.out.println("WindowsXPErind");
          setVea_raskusaste(vea_raskusaste+2);
      }
  }
  double parandamiseAeg(){
      return getVea_raskusaste()*1.5;
  }
  public String toString() {
      return "Arvuti [tootja=" + tootja + ", mudel=" + mudel + ", lisainfo="
              + lisainfo + ", järjekorranumber=" + jrnumber + ", vea raskusaste="
              + vea_raskusaste + ", kiirtellimus=" + kiirtellimus
              + ", parandamise aeg=" + parandamiseAeg() + "]";
  }
  public int compareTo(Arvuti arvuti){
      if(this.isKiirtellimus()==true &amp;&amp; arvuti.isKiirtellimus()==false) return -1;
      else if(this.isKiirtellimus()==false &amp;&amp; arvuti.isKiirtellimus()==true) return 1;
      else{
          if(this.getJrnumber()&lt;arvuti.getJrnumber())return -1;
          else if(this.getJrnumber()&gt;arvuti.getJrnumber())return 1;
          else return 0;
      }
  }
  
  }
  </code></pre>
  
  <p>Exception in thread "main" java.lang.Error: Unresolved compilation problem:</p>
  
  <pre><code>Unhandled exception type ClassNotFoundException
  
  at Peaklass.main(Peaklass.java:36)
  </code></pre>