This is follow-up on my question:
error in java basic test program
This is still confusing me. So specific problem is:
I already have a package and directory done. say com.learn.java.mypackage
$ pwd
.../com/learn/java/mypackage
and here I want to create a test program in the same package and execute it.
$cat TestPackage.java
package com.learn.java.mypackage;
public class TestPackage
{
public static void main(String args[])
{
System.out.println("Hello World\n");
}
}
$ javac TestPackage.java
// runs file
$ Java TestPackage
Exception in thread "main" java.lang.NoClassDefFoundError: TestPackage (wrong name: com/learn/java/TestPackage)
if java runtime wants to make sure that a file belonging to a package lives in the same named directory, it is true here. Then why does it still crib?