Re: Code Exercise From Book
Please use [ CODE] [ /CODE](no spaces) to contain your code. Also, it works fine for me, so I would like more info. What IDE are you using, stuff like that.
Re: Code Exercise From Book
I just set the the environment varables to my C:\Java\jdk1.7.0_09\bin folder and am compiling and running from the command prompt using the javac and java commands. No IDE.
Re: Code Exercise From Book
Well, I figured it was either that or an IDE, but I couldn't think of the word. Either way, it works fine for me. So it's probably something to do with the path, but who knows.
Re: Code Exercise From Book
What? how could it have something to do with the path? and, should all my classes be in different files?
Re: Code Exercise From Book
Since they are different classes, they should be in different .java files, also there needs to be a .class file for each as well.
Re: Code Exercise From Book
well, that's what the compiler does for me, correct? creates the .class files for me to then execute? Also, i added C:\Java\jdk1.7.0_09\bin to the end of the PATH in the environment variables, idk where else to go with that.
Re: Code Exercise From Book
Quote:
Originally Posted by
gordlonious
This is all in one source file, the book even says that the code all represents one complete source file. It doesn't compile, I get an Error stating that it can't find the main method in class DrumKit. Then, a friend told me that each class should be in a seperate file, tried that, both will compile but won't run. I doing these from the command prompt. Please help!
From what I can see in you code this is should compile. Even if you place both class in a single file, for instance in a file called DrumKit.java. You obviously cannot run the DrumKit class because it doesn't have the main(String[] args) method. You can only run the DrumKitTestDrive class becuase it has the main method defined.
Re: Code Exercise From Book
gordlonious, please go through the Forum Rules -- particularly the third paragraph.
db