This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compilation error" Watch "compilation error" New topic
Author

compilation error

joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117


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
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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.
Swapnil Trivedi
Ranch Hand

Joined: Jun 06, 2006
Posts: 106
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 ]

SCJP 5.0<br />-----------<br />"Help Ever && Hurt Never"
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
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

Joined: Jun 06, 2006
Posts: 106
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: compilation error