title: Jython NoClassDefFoundError when using a class from another class
body: <p>I am trying to use 2 Java defined classes in python using jython 2.7.0 but after i ran my script it throws a java.lang.NoClassDefFoundError </p>
  
  <p>Those are my 2 Java classes:</p>
  
  <p>Hello.java</p>
  
  <pre><code>package hello;
  
  public class Hello {
      public void printMsg(){
          System.out.println("check out this cool message");
      }
  }
  </code></pre>
  
  <p>Hello2.java</p>
  
  <pre><code>package hello;
  
  public class Hello2 {
      public void printHelloMsg(){
          Hello msg = new Hello();
          msg.printMsg();
      }
  }
  </code></pre>
  
  <p>I compiled them with:</p>
  
  <pre><code>hello$ javac Hello.java Hello2.java
  </code></pre>
  
  <p>Then created a jar file with:</p>
  
  <pre><code>hello$ jar cf hello-jar.jar *.class
  </code></pre>
  
  <p>And my python script that is supposed to use the Hello2 class, which uses Hello class:</p>
  
  <p>hello.py</p>
  
  <pre><code>import Hello2
  
  h = Hello2()
  h.printHelloMsg()
  </code></pre>
  
  <p>After i ran my script with jython using:</p>
  
  <pre><code>hello$ jython -J-cp ./hello-jar.jar hello.py
  
  Traceback (most recent call last):
    File "hello.py", line 1, in &lt;module&gt;
      import Hello2
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at org.python.core.Py.loadAndInitClass(Py.java:991)
      at org.python.core.Py.findClassInternal(Py.java:926)
      at org.python.core.Py.findClassEx(Py.java:977)
      at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:133)
      at org.python.core.packagecache.PackageManager.findClass(PackageManager.java:33)
      at org.python.core.packagecache.SysPackageManager.findClass(SysPackageManager.java:122)
      at org.python.core.PyJavaPackage.__findattr_ex__(PyJavaPackage.java:134)
      at org.python.core.PyObject.__findattr__(PyObject.java:946)
      at org.python.core.packagecache.PackageManager.lookupName(PackageManager.java:141)
      at org.python.core.JavaImporter.find_module(JavaImporter.java:40)
      at org.python.core.JavaImporter.find_module(JavaImporter.java:26)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
  
  java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Hello2 (wrong name: hello/Hello2)
  </code></pre>
  
  <p>What could possibly be the problem here?
  Thanks in advance </p>