public static Reservation[] openBinaryFile( String fileName )
{
Reservation [] objArray = null;
try
{
ObjectInputStream inStream = new ObjectInputStream(
new FileInputStream( fileName ) );
objArray = (Reservation[])inStream.readObject();
inStream.close();
}
catch( ClassNotFoundException e )
{
System.out.println( "Exception: ClassNotFoundException." );
}
I have the class included, but why do I get an exception? The class is in the same package as the others. Why am I getting this exception?
EDIT: Here is the stack trace run: java.lang.ClassNotFoundException: Reservation at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604) at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575) at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1624) at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323) at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) at myViewer.DatabaseFile.openBinaryFile(DatabaseFile.java:42) at myViewer.Viewer.(Viewer.java:175) at myViewer.Viewer.main(Viewer.java:188)
Reservation
was, it wouldn't get past the array declaration. – danbenClassDefNotFoundError
or the compilation would just have failed, because the same class is already imported. – BalusCserialVersionUID
as perjava.io.Serializable
javadoc in the class file at the both sides. – BalusC