Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.lang.ClassNotFoundException - at compile time???

807597Mar 17 2004 — edited Feb 10 2005
Hi,
I have this code:
ArrayList remoteEvents = new ArrayList();
ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
...
...
...
remoteEvents = (ArrayList)ois.readObject();  //line 615
and when I compile I get this error:

[615] unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown
remoteEvents = (ArrayList)ois.readObject();
^

I looked at the documentation for java.lang.ClassNotFoundException and I can't see why I would have to catch it in this line of code. I have other places in my file where I am trying to read in ArrayLists over the socket and that code compiles/works just fine. The only thing different about this code is that it is in the run() method of a thread.

Any ideas?


Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 10 2005
Added on Mar 17 2004
5 comments
421 views