• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rectangle versus java.awt.Rectangle

 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21558
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic