Make both class as public,you cant access class outside the package if it is not public.Atleast make Box class as public
package p1;
public class Box
{
int w=12;
int d=30;
int c=40;
}
Command is java -cp c:\validation p2.Demo
where c:\validation folder is where both p1 and p2 folders are present.