When you run "java Prog1", java search for a class named "Prog1" in its class
path (usually current directory), not for a file named "Prog1" or "Prog1.class".
But when you run "java Prog1.class", java search for a class named "class" in
"Prog1" package in its class path. There's no such class that why it returns
NoClassDefFoundError.