This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes To Phrase it another way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "To Phrase it another way" Watch "To Phrase it another way" New topic

To Phrase it another way

mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
Why would a class upon compile not see the class it is extending? This is referring to my other post earlier. My OrderWithCharge class cannot see the Order class. Am I not using the [BOLD]extends[/BOLD] correctly? I have an Order.class file in the directory......... Thanks for your time and expertise..

Thank you Oh Lord<br />For the white blind light<br />A city rises from the sea<br />I had a splitting headache<br />from which the future's made<br />--morrisson
le taylom
Ranch Hand

Joined: Dec 01, 2000
Posts: 44
A basic example:

The parent and child CAN be in seperate packages ( package is a synonym for directory ) as long as they reference each other correctly and the variables/methods within the parent have the right access privileges.
Try this example out, and post more questions back if needed as i'm not sure if this completely answers your question!
When you compile the above example you will get 2 directories, matt and notmatt. In matt you will get the child and main classes and in notmatt the parent class.
[ November 28, 2002: Message edited by: le taylom ]
mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
I am going to post all my code. Hopefully it is not too much and becomes confusing. All my classes should be in the same package. I am using a batch file to compile and run these classes. Here is the code from parent on down:

The last class just instantiate the previous and is supposed to display with the toString() method. The problem is that the child class OrderWithCharge is not compiling and is giving the error of cannot resolve symbol, which is pointing at all the references to super and to the extends Order line. Dont give me the code per se but rather what is wrong with it. This is a class project and I am supposed to code it myself but can look for help. Thanks for the help.
Wilfried LAURENT
Ranch Hand

Joined: Jul 13, 2001
Posts: 269
Drop the batch file to compile. Compile Order.class first, then OrderWithCharge.
See if it works. If not, then it is probably because you have classpath problem.
Check where your .class are generated and see if this directory appears in your classpath.
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
Are you compiling in a good order?
Make a javac *.java, so you don't have to worry about the order to compile.
Hope it helps you!

By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
For the class we are to use a batch file to compile. Of course I did compile Order then OrderWithCharge, and then TestOrderAmt. Now it seems to be compiling fine but no output on the screen.??? Work will continue this evening on this problem any ideas about things to change in the code would be welcome. Thanks for any time that you may spend on this. I am sure I will have more questions out here on the next two parts of this project. As always I do not want the code written for me, just ideas and maybe hints. I am supposed to be learning this stuff after all...
mike hengst
Ranch Hand

Joined: Oct 19, 2002
Posts: 43
OK so now everything runs pretty close to the right way. In my batch file I am putting the .class files in another directory. I had those messed up. It is straightened out now. Only problem is my OrderWithCharge is not overriding the Order calcTotal() method. It keeps displaying the fee with handling charge a the same as without the handling charge.??? I will keep working on it, but if someone sees something amiss.........
I agree. Here's the link:
subject: To Phrase it another way