Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

importing my own class, I get an error

Status
Not open for further replies.

neos

Programmer
Oct 28, 2000
36
0
0
CA
I have written a class called Face and it compiled correctly. But I can't import it correctly. Both files are in the same directory.

import Face; // thats how I import it

and theres the error below...

D:\src\Face\Main.java:3: '.' expected
import Face;
^
1 error

Any suggestions?

shaun
 
I did that, but now I get the error

D:\src\Face\Main.java:3: package Face does not exist
import Face.*;
^
1 error

The Face.class file is there though.

shaun
 
sorry i thought it was a package Face. When you use import statement, you have to use a package name. Package is used to resolve coflicts if you happen to have classes with the same name but exist in a different package.

But since the two classes are in the same package, get rid of
the import statement.

if you have a TestFace.java, then just do this:-

public class TestFace{

public void myFace(){
Face fc = new Face();

//call you face method class
}

}


~za~
You can't bring back a dead thread!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top