Duplicate :
|
The following code throws a "ClassNotFoundException: int" exception: import java.io.*; public class Primtest extends Object { /** Creates new Primtest */ public Primtest() { } /** * @param args the command line arguments */ public static void main (String args[]) { try { ByteArrayOutputStream o = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(o); Class c = int.class; oos.writeObject(c); oos.close(); o.close(); ByteArrayInputStream i = new ByteArrayInputStream(o.toByteArray()); ObjectInputStream ois = new ObjectInputStream(i); c = (Class)ois.readObject(); } catch (Exception e){ e.printStackTrace(); } } }