• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

compilation error

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I get a compilation error stating
cannot reference x before supertype constructor has been called..
Do i get this error just because it is specified in the JLS that instance variables cannot be referenced in constructor before call to super?

I am not able to understand this, because any way x is initialised to 5 before we make a call to super constructor.
Am I missing something silly..
Regards,
Joshua
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The superclass will be initialized before the subclass. If x were to be resolved to 5 and sent to the constructor of the superclass, then the subclass would have to be initialized before the superclass.
 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Keith........It was a real brainer problem
Now it's compiling but giving runtime exception
"NoClassDefFoundError"...May be I am wrong somewhere..Can u pls help.


Regards
Swapnil
[ June 21, 2006: Message edited by: Swapnil Trivedi ]
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you talking about the code from Joshua?

Can you post the changes you made to it?

It sounds like you had a problem with either the command line or CLASSPATH.
[ June 21, 2006: Message edited by: Keith Lynn ]
 
Swapnil Trivedi
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Keith,
I am sorry for my last post actually yesterday I downloaded the enthuware database so for that I made some changes in my classpath and I forgot to include the current directory in it. So, that's why it was giving error...Sorry for your inconvenience

Everything is working fine now...including Joshua's code

again thanks's alot for your help...


regards
Swapnil

[ June 21, 2006: Message edited by: Swapnil Trivedi ]
[ June 21, 2006: Message edited by: Swapnil Trivedi ]
reply
    Bookmark Topic Watch Topic
  • New Topic