• Post Reply Bookmark Topic Watch Topic
  • New Topic

compiler error saying method of serializable to be overridden  RSS feed

 
Greenhorn
Posts: 28
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


this is returning error saying a method serialize is to be overridden. serializable is a marker interface then how come??
plzz help...

/*the code is present in myjp folder*/
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when I run above code I got output as:
aleha
after :aleha
 
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it to compile and run, despite the dreadful design of your Doggy class. You ought to set up those values in a constructor, rather than a method to set up those fields.
Please explain how you got that error in the first place.
 
Achin Gupta
Greenhorn
Posts: 28
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir i am still getting the same error. i am using jdk1.6 and compiled it with javac myjp/pr460.java and it doesn't compile giving error
Pramod P Deore wrote:when I run above code I got output as:
aleha
after :aleha
 
Achin Gupta
Greenhorn
Posts: 28
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i accept the initialization of Doggy instances is not good but legal and still the code is not working. i am using jdk1.6 and compiling it with javac myjp/pr460.java
Campbell Ritchie wrote:I got it to compile and run, despite the dreadful design of your Doggy class. You ought to set up those values in a constructor, rather than a method to set up those fields.
Please explain how you got that error in the first place.
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
compile it using as javac <Your class name>.java. Here in your case it must be ===> javac Doggy.java

not as==>javac myjp/pr460.java
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry my mistake in above code you have to run your program like:
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A possible reason why it doesn't work for Achin Gupta could be that he has defined his own interface called Serializable, and the Java compiler is picking that up instead of the standard java.io.Serializable.

If that's the case, then delete your own Serializable interface (and class file if you have it).
 
Achin Gupta
Greenhorn
Posts: 28
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes sir this was the problem now it compiles and runs... thank you.!!
Jesper de Jong wrote:A possible reason why it doesn't work for Achin Gupta could be that he has defined his own interface called Serializable, and the Java compiler is picking that up instead of the standard java.io.Serializable.

If that's the case, then delete your own Serializable interface (and class file if you have it).
 
Achin Gupta
Greenhorn
Posts: 28
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir the problem is solved.. thank you..!! i had a serializable class already..
Pramod P Deore wrote:Sorry my mistake in above code you have to run your program like:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!