Remember when using a classpath, the last directory in the path must be the
super-directory of the root directory for the package.
this means
if your class A is
and class B is
and suppose your A.class file is here:
bin/p1/packagea/A.class
then p1 is the root-directory for the package p1.packagea;
and bin is the super directory of p1 package's root-directory.
So in your classpath bin should be last directory.
suppose your dir structure is:
project/bin/p1/package1/A.class
project/p2/B.java
and you are in project directory then you need to give bin in classpath while compiling B.java