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)


 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);

            } catch (IOException ex) {
                System.out.println("Something went wrong...");
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(AirTrafficControl.class.getName()).log(Level.SEVERE, null, ex);


 ServerSocket server = new ServerSocket(1025);
        Socket socket = server.accept();
        ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
        Server messageObject = (Server) in.readObject();


    //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 ?

I have a class called AirplaneDetails on Client side, but do not have on Server side..

Do I need to have AirplaneDetails on a server and client side ?? On Client side in AirplaneDetails class I have constructor and some getters to be able to create an object..

I guess I dont need again getters and setters on the server side.. Am I right ? If so, what should go in the AirplaneDetails class on Server side??


I have the same classes on both machines, but still I am getting exactly the same error

It looks like AirplaneDetails is an inner class of airtrafficcontrol (?), so you will need the whole airtrafficcontrol class on both machines.

This question has already been answered. Start a new discussion instead.