i am trying to send an Object via socket.
its object Net
public class Net {
public List<NetObject> objects; //= new ArrayList<NetObject>(); // place + transition
public List<ArcObject> arcs; // = new ArrayList<ArcObject>(); // arcs - objects
}
here is the ArcObject class
public class ArcObject implements Observer {
public NetObject o1;
public NetObject o2;
public String parameter;
}
and here is NetObject class
public class NetObject implements Observer{
public int index; // index of object
public int type; // type - place=1, transition=2 ...
public int x; // position
public int y;
public List<Integer> tokens ; //list of tokens
//public List<ArcObject> arcs = new ArrayList<ArcObject>();
public String guard;
// etc...
}
then i connect to the server
String computername=InetAddress.getLocalHost().getHostName();
kkSocket = new Socket(computername, 4444);
OutputStream outputStream = null ;
ObjectOutputStream out = null ;
outputStream = kkSocket.getOutputStream();
out = new ObjectOutputStream(outputStream);
and then i try to send object via socket
out.writeObject(petriNet); //petriNet object is from class Net
but the client gives me an exception
java.io.NotSerializableException: petri.ArcObject
but ArcObject class cant implements Serializable, since it already implements Observer, so how am i supposed to send object via socket which has two lists included. any ideas ?