Hi there,
I have two seperate programs - one is a Client, and the other one is Server. I am trying to send an object from Client to Server, but I am getting following error:
Exception in thread "main" java.lang.ClassNotFoundException: airtrafficcontrol.AirplaneDetails
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:626)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1613)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1518)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1774)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:371)
at server.Server.main(Server.java:34)
Client:
String make = tfMake.getText().trim();
String airlanes = tfAirlanes.getText().trim();
String to = tfTo.getText().trim();
String from = tfFrom.getText().trim();
out = new ObjectOutputStream(socket.getOutputStream());
AirplaneDetails airplaneDetails = new AirplaneDetails(make, airlanes, to, from);
out.writeObject(airplaneDetails);
} catch (IOException ex) {
System.out.println("Something went wrong...");
} catch (ClassNotFoundException ex) {
Logger.getLogger(AirTrafficControl.class.getName()).log(Level.SEVERE, null, ex);
}
Server
ServerSocket server = new ServerSocket(1025);
Socket socket = server.accept();
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
//Receive
Server messageObject = (Server) in.readObject();
System.out.println(messageObject);
//radius = in.readObject();
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
// double area = radius * 100;
System.out.println("Received at: " + new Date() );
Any idea how to solve it ?