The issue was that the class path needs to be set for each command (javac and java):
Attempted Steps
-
instead of going to subpackage, compile HelloWorld.java from the top_level:
$javac -cp . importpackage/subpackage/HelloWorld.java
-
compile CallPackage.java in the same way:
$javac -cp . CallPackage.java
-
run the file using the class path also:
$java -cp . CallPackage
NOTE: running “$java CallPackage” will give an error “Error: Could not find or load main class CallPackage”
In summary, during each step, the class path must be specified. It worked after running it as such.