title: Searching for files in a jar file (Including Jython class files in a jar file to be found)
body: <p>Following <a href="http://www.jython.org/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications" rel="nofollow noreferrer">Using Jython Within Java Applications</a>, I could integrate Java and Jython (Java methods can call python scripts). The python code is located inside <code>py</code> directory. The Jython uses <code>sys.path.append("py")</code> command to find the Jython scripts.</p>
  
  <p>Then, I tried to integrate all the files into a single jar file. </p>
  
  <p>For the pre step, I could generate one jar file, and copied the py directory along side with the jar file, and it works fine. I used IntelliJ IDEA for generating a jar file. </p>
  
  <pre><code>│   └── py
  │       ├── Context$py.class
  │       ├── Context.py
  │       ├── Host$py.class
  │       └── Host.py
  ├── aggregationPython.jar &lt;-- Generated jar file 
  </code></pre>
  
  <p>For the next step, I tried to copy the py directory inside the jar file, I also used IntelliJ for that. </p>
  
  <p>I checked that the jar file has the py directory in the jar file. You see that the py directory is located at the root of jar file. </p>
  
  <p><img src="https://i.stack.imgur.com/GcKQr.png" alt="enter image description here"></p>
  
  <p>However, when I executed the jar file, I got an error saying the jython module is missing.</p>
  
  <pre><code>&gt; java -jar aggregationPython.jar 
  Exception in thread "main" ImportError: No module named Host
  </code></pre>
  
  <p>What might be wrong? I assumed the py directory can be stored in a jar file to be found just like it is found outside the jar file. What's wrong with this assumption? </p>