Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

compiler error saying method of serializable to be overridden

 
Greenhorn
Posts: 28
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when I run above code I got output as:
aleha
after :aleha
 
Marshal
Posts: 74687
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry my mistake in above code you have to run your program like:
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
reply
    Bookmark Topic Watch Topic
  • New Topic