ObjectInputStream over sockets Problem

I am trying to call a method on the server from the client. I called a new instance of the class and wrote the new instance as an object to the ObjectOutputStream. I wrote an interface on the client side. Am I able to do this?(or allowed to) Oh yeah the server is on a different machine. The error im getting from the client is:

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: java.lang.Runtime

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1311)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1877)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1801)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1679)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1307)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:357)

at cmd_line.Network.sendFile(Network.java:65)

at cmd_line.EpkgUtil.addEpkg(EpkgUtil.java:201)

at cmd_line.EpkgArchiveClient.go(EpkgArchiveClient.java:198)

at cmd_line.EpkgArchiveClient.main(EpkgArchiveClient.java:214)

Caused by: java.io.NotSerializableException: java.lang.Runtime

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1085)

at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1423)

at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1395)

at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1338)

at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1083)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:309)

at ServerThreads.run(ServerThreads.java:68)

and from the server im getting:

Exception: java.lang.Runtime

Client code:

oos.writeUTF("file");

oos.writeObject(v);

oos.flush();

EpkgArchiveServerUtil he = (EpkgArchiveServerUtil) objIn.readObject();

he.Test();

objIn.close();

oos.close();

Client interface class:

publicinterface EpkgArchiveServerUtilextends Serializable{

publicvoid Test();

}

Server code:

if(ois.readUTF().equals("file")){

System.out.println("got to the file decider");

Vector v = (Vector) ois.readObject();

EpkgArchiveServerUtil e =new EpkgArchiveServerUtil();

oos.writeObject(e);

oos.flush();

ListIterator iter = v.listIterator();

while(iter.hasNext()){

System.out.println((String)iter.next());

}

ois.close();

oos.close();

oos.close();

}

EpkgArchiveServerUtil class:

publicvoid Test(){

System.out.println("Hell yea it worked");

}

[3419 byte] By [Mjacobsa] at [2007-11-27 9:02:54]
# 1
Looks like one of the fields of the object you are trying to serialize is not serializable.Have you included the complete listing of the class you are trying to serialize?
rituraj_tiwaria at 2007-7-12 21:34:13 > top of Java-index,Core,Core APIs...
# 2
You must implements Serializabledo not extends itAnd the class that implements Serializable (and will be serialized) must have all its variables Serializables too.cya
pbulgarellia at 2007-7-12 21:34:13 > top of Java-index,Core,Core APIs...
# 3

It seems you are trying to serialize an object of class java.lang.Runtime. This can only mean that one of your serializable classes has a non-static non-transient data member of type Runtime. As Runtime isn't serializable neither is the class that contains it.

You don't need that data member anyway, just use Runtime.getRuntime() everywhere.

ejpa at 2007-7-12 21:34:13 > top of Java-index,Core,Core APIs...