• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

import

 
Ron Lam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have try an example from "A programmer's Guide to Java Certification" that contain the following code snippet.

// Class Clown
package wizard.pandorasBox;
public class Clown implements Magic {
LovePotion tlc;
}

class LovePotion {

}
// Class Client
import wizard.pandorasBox.*;
public class Client {

Clown performerOne;
wizard.pandorasBox.Clown performerTwo;

// LovePotion moreTLC;
// Magic MAGICIAN;

}
The compiler complain the following when I compile Client.java:
C:\My Document\Java exercise\Chapter 4\Example 4.5\Client.java:11: cannot access Clown bad class file: C:\My Document\Java exercise\Chapter 4\Example 4.5\Clown.java file does not contain class Clown
What wrong with me?
 
Amit KumarS
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hiii..
it would be better understandable if you put the hierarchies of the folder where u r putting your java files and where r u compiling form.. what are names of the files..
then we would be able to help you better... by the way on first look it looks like you haven't compiled the Clown class first and second possible reson might be that you have both the classes in same folder.
correct me if i am wrong.. or give us a better view to ponder upon..
Thanks
Amit
 
Ron Lam
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Amit,
Sorry for my late respond.
Both source files (Clown.java and Client.java) are located at C:\My Document\Java exercise\Chapter 4\Example 4.5\ and I have compile Clown.java first. Secondly, the class files hierarchies seems correct.
Indeed, if I change the statement "import wizard.pandorasBox.*;" to "import wizard.pandorasBox.Clown;", it does work. That means, it can locate the Clown.class from the wizard.pandorasBox.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic