confused about compiling a basic java test program with package
<p>This is follow-up on my question:</p>

<p><a href="http://stackoverflow.com/questions/7593320/error-in-java-basic-test-program">error in java basic test program</a></p>

<p>This is still confusing me.
So specific problem is:</p>

<p>I already have a package and directory done.
say com.learn.java.mypackage</p>

<pre><code>$ pwd
.../com/learn/java/mypackage
</code></pre>

<p>and here I want to create a test program in the same package and execute it.</p>

<pre><code>$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)
</code></pre>

<p>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?</p>
