user2942023
user2942023

Reputation: 1

implement interface in java

I am using an interface in java. I want to put the data in a file and when i compile the program appear this error:

java.io.InvalidClassException: Teatro; local class incompatible: stream classdesc      serialVersionUID = -8638492166751354209, local class serialVersionUID = 8721614984870769537
at java.io.ObjectStreamClass.initNonProxy(Unknown Source)
at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
at java.io.ObjectInputStream.readClassDesc(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at CarteleraProg.main(CarteleraProg.java:107)

error Teatro; local class incompatible: stream classdesc serialVersionUID = -8638492166751354209, local class serialVersionUID = 8721614984870769537

 public interface Playable {

public void ImprimirDatos();

 }

 public void ImprimirDatos(){
System.out.println ("TITULO TEATRO: " + getTitulo());
System.out.println ("DIRECTOR: " + getDirector());
System.out.println ("ESCENOGRAFO: " + getEsceno() );
System.out.println ("FECHA: " + getFecha());
   }

What can i do to solve that?

Thank you very much

Upvotes: 0

Views: 167

Answers (1)

Arne Burmeister
Arne Burmeister

Reputation: 20614

You (or the library you use) have changed the class Teatro to create another serial format (changed/added/removed a member, changed the superclass, ...) after you have written an object of class Teatro to a stream.

If you are really sure, use a fixed id:

public class Teatro implements Serializable {
  private static final long serialVersionUID = -8638492166751354209L;

  ...
}

Upvotes: 1

Related Questions