This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes import Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "import" Watch "import" New topic


Ron Lam

Joined: Sep 22, 2003
Posts: 6
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
C:\My Document\Java exercise\Chapter 4\Example 4.5\ cannot access Clown bad class file: C:\My Document\Java exercise\Chapter 4\Example 4.5\ file does not contain class Clown
What wrong with me?
Amit KumarS
Ranch Hand

Joined: Oct 10, 2003
Posts: 100
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..

****************************<br />In 24 hrs Earth rotates once on its Axis.
Ron Lam

Joined: Sep 22, 2003
Posts: 6
Dear Amit,
Sorry for my late respond.
Both source files ( and are located at C:\My Document\Java exercise\Chapter 4\Example 4.5\ and I have compile 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.
I agree. Here's the link:
subject: import
It's not a secret anymore!