Forums Register Login

Howto Import Class

+Pie Number of slices to send: Send
Im using Eclipse, and I want to import StdDraw.java
how to do that
I tries
import StdDraw
import StdDraw.java
import StdDraw.class

all are not working, how to import the class?
+Pie Number of slices to send: Send
 

Originally posted by Sam Benry:
Im using Eclipse, and I want to import StdDraw.java
how to do that
I tries
import StdDraw
import StdDraw.java
import StdDraw.class

all are not working, how to import the class?



You need to specify the class, not the file where the class is in.

Open the file, and note the package that the StdDraw class is in. Let's say that it's in some.package, then import via...

import some.package.StdDraw;

Just change some.package to the actual package that StdDraw is in.

Henry
+Pie Number of slices to send: Send
A couple more points....

First, with Eclipse it is easier than that -- you don't need to open the file. Eclipse will list the package that the java file is in via the package explorer.

Second, if the class that you want to import is in a different project, don't forget to have your project refer to the other project.

Henry
I am a man of mystery. Mostly because of this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 41228 times.
Similar Threads
JetSpeed Portal Development
Convert Swing frame+label to Applet?
importing a class..
Drawing Whirl
I don't understand what I'm being asked.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 05:47:45.