Java classes are identified by their
qualified names. If a class is in a named package, its qualified name is myPackage.MyClass.
So you will
not find a class called "Test1" in the "pack" directory. Instead, you will find pack.Test1 in the directory that is the
parent of "pack."
Unless you specify a classpath, Java's default is to look for classes in the current directory. So...
You want to set the current directory to the
parent of "pack." Then compile with...
javac pack/Test2.java That way, when Java looks in the current directory (the parent of "pack") for the class pack.Test1, it will find it.
If Java still can't find Test1, then you have probably set a system classpath that does not include a dot (.) for the current directory. In that case, try using the classpath flag to specify the current directory...
javac -cp . pack/Test2.java Note the spaces before and after the dot. If this works, but it did not work without the "-cp . " then
you should add a dot to your system classpath.