aspose file tools*
The moose likes Applets and the fly likes Rectangle versus java.awt.Rectangle Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Rectangle versus java.awt.Rectangle" Watch "Rectangle versus java.awt.Rectangle" New topic
Author

Rectangle versus java.awt.Rectangle

Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 136
    
    1
I am trying to compile the Scribble applet from Chapter 1 of Java in A Nutshell 2nd edition (JDK 1.1).

there is a line inside the action() method of the Scribble class (derives from Applet):



my JDK 1.5.0.10 javac compiler gives this error on that line:

I don't understand what the compiler is telling me. Any help would be appreciated.
Jeff Storey
Ranch Hand

Joined: Apr 07, 2007
Posts: 230
Red, could you post the class' code in its entirety (for that one class)? This way we can see your imports as well. Thanks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

That means you have a class named Rectangle that isn't in any package. Probably you wrote that class yourself. When you use the unqualified name "Rectangle" in your code, it means that class. If you can't get rid of that class you will have to change your code to use the qualified name of the class, like this:But I would get rid of it if I were you. You should be putting all your classes into packages anyway, so you don't have to deal with problems like this.
Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 136
    
    1
Originally posted by Jeff Storey:
Red, could you post the class' code in its entirety (for that one class)? This way we can see your imports as well. Thanks.


[ February 19, 2008: Message edited by: Red Smith ]
Red Smith
Ranch Hand

Joined: Aug 05, 2007
Posts: 136
    
    1
Originally posted by Paul Clapham:
That means you have a class named Rectangle that isn't in any package. Probably you wrote that class yourself. When you use the unqualified name "Rectangle" in your code, it means that class. If you can't get rid of that class you will have to change your code to use the qualified name of the class, like this:


Adding java.awt. did get rid of the error. Thanks.


Originally posted by Paul Clapham:
[QB
But I would get rid of it if I were you. You should be putting all your classes into packages anyway, so you don't have to deal with problems like this.[/QB]


I had a file called RanchTest.java that had a Rectangle class in it. I deleted the RanchTest.class file but still got the error without java.awt. prepended.
I changed the Rectangle class in RanchTest.java to ARectangle and recompiled. But that still gives me the same error without java.awt. prepended.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Rectangle versus java.awt.Rectangle