System: Server kann nicht senden -> Exception.java.io.NotSerializableException: sun.awt.image.ToolkitImage
System: Server kann nicht empfangen -> IOException.java.io.InvalidClassException: CardHeroes.Karte; local class incompatible: stream classdesc serialVersionUID = -8683094360508585683, local class serialVersionUID = 7039260118284666046
System: Server kann nicht senden -> Exception.java.io.NotSerializableException: sun.awt.image.ToolkitImage
System: Server kann nicht empfangen -> IOException.java.io.StreamCorruptedException
import java.io.*;
import java.net.*;
class testobj implements Serializable
{
public void bla()
{
System.out.println("huhu");
}
int testvar;
}
public class netservertest
{
public static void main(String[] args) throws IOException, ClassNotFoundException
{
ServerSocket ConnectionSocket=new ServerSocket(9999);
Socket ClientConnection=ConnectionSocket.accept();
ObjectInputStream StreamIn=new ObjectInputStream(ClientConnection.getInputStream());
testobj[] a=new testobj[2];
a[0]=new testobj();
a[1]=new testobj();
a[1].testvar=5;
System.out.println(a[1].testvar);
a=(testobj[])StreamIn.readObject();
System.out.println(a[0].testvar);
a[0].bla();
}
}
import java.io.*;
import java.net.*;
class testobj extends Object implements Serializable
{
public void bla()
{
System.out.println("huhu");
}
int testvar;
}
public class netclienttest
{
public static void main(String[] args) throws IOException
{
Socket ConnectionSocket=new Socket(Inet4Address.getLocalHost(),9999);
ObjectOutputStream StreamOut=new ObjectOutputStream(ConnectionSocket.getOutputStream());
testobj[] b=new testobj[2];
b[0]=new testobj();
b[1]=new testobj();
b[0].testvar=1234;
StreamOut.writeObject(b);
}
}
implements Serializable
ObjectOut.reset();