Using plain javac the default classpath contains the work directory where
javac is executed.
For production
you should look into some build tool like
Maven.
Example:
In directory
java_packs you have the two source files located
Compile the
packageb/B.java
After that
javac create both class files since its able to resolve the dependency inside
packageb.B
Execute the code inside
java_packs
... or provide
java with an explicit class path that contains
java_packs: