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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 files in the same folder .. could compile only 1 of them ..

Status
Not open for further replies.

sophie24

Programmer
Jan 20, 2002
20
0
0
CH
i have some code in the main class A and some in another class B. i compile class B with no problems, but if i try to compile the main class A, which has objects and methods referenced to the class B, i get allways an error. i think that i have set the path and classpath correctly and both files are in the same folder, why cannot find my main class A the objects created by class B which are also in the same folder? Also i have tried to put those files in a package, the problem occours again. Many thanks for every help and usefull tip :)


regards

------------------------------------------------------------
public class classA {
public static void main(String[] args) {
classB dosomething = new classB();
dosomething.setX(77);
}
}
------------------------------------------------------------public class classB {
private int xtest;
public void setX(int ab) {
xtest = ab;
}
public int getX() {
return xtest;
}
}
------------------------------------------------------------
 
i am not quite sure but isnt it so that java first searches the referenced class files in the same folder and if it doesnt exists it goes to the classpath ?

and is there a solution for the slash/backslash problem with windows ? i have tried to compile a package but the jvm reads 'folder1\folder2\file.class' as 'folder1/folder2/file.class' so the same package runs perfectly in linux.

regards
 
You probably definitely has to do with the CLASSPATH. Make sure you have . on your CLASSPATH. This will make the compiler look in the current directory for the necessary class files as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top