0

I am writing a java code in eclipse . But here eclipse show me that "Rectangle is not a build in java class " . What can I do ? The error is pictured in the following image .

enter image description here

The main problem is that I have written the following line in android in eclipse . But eclipse show me error . What can I do to resolve this error ?

  Rectangle rect = new Rectangle(0, 0, (int) page.getBBox().getWidth(),
                                     (int) page.getBBox().getHeight());

I have imported the necessary packages to support this "Rectangle" class . But the conditions of situation is same as before .

import java.awt.Rectangle ; 
osimer pothe
  • 2,827
  • 14
  • 54
  • 92

1 Answers1

2

You have to import java.awt.Rectangle so that the Java compiler knows which Rectangle class you're referring to.

You can let Eclipse create your import statements by right clicking on the editor view and left clicking on Source -> Organize Imports.

Gilbert Le Blanc
  • 50,182
  • 6
  • 67
  • 111
  • to expand on this answer, it's "built-in" in that it's part of the standard java api found here: http://docs.oracle.com/javase/6/docs/api/ but it's not part of the "default" package that doesn't require import statements the way the Math and Language packages are. eclipse SHOULD be giving you a little red error button with the option that says something like "add import statement" – Jeff Hawthorne Feb 12 '13 at 15:06
  • Look at the screenshot more closely: he's using Android – David Lavender Feb 12 '13 at 15:15
  • I have imported the necessary package . But eclipse show me error . Why ? – osimer pothe Feb 12 '13 at 15:34
  • I have come to know that android does not support "java.awt.Rectangle" ? Is it right ? – osimer pothe Feb 12 '13 at 15:34
  • 1
    I didn't notice the Android tag. There's android.graphics.Rect. – Gilbert Le Blanc Feb 12 '13 at 15:39