I thought I new this, but when I create an object out of an class in a seperate file, it only compiles if that class is defined in the same directory, or if I import it from the library. I assumed it used classpath to search for the included class files, but when I add a random directory to classpath(and only place that file there), it still complains that the class is not defined and won’t compile. Where does it know to look for classes at compile time?
Example
public class SomeClass {
public SomeOtherClass SoC; // If this class is not in library or same directory -- won't compile.
}
Correct. Your classes need to be in the classpath, or in a
.jarthat you specify.When compiling you would use
You then
importwhatever you need in your .java files (your code)