title: How To Bundle .jar Files with Pyinstaller
body: <p>How do you get <a href="http://www.pyinstaller.org" rel="noreferrer">pyinstaller</a> to bundle .jar files as archives for a python project that utilizes them?</p>
  
  <p>For instance, to make an exe with (I am using <a href="http://pyjnius.readthedocs.org/en/latest/" rel="noreferrer">pyjnius</a> for handling the <a href="https://code.google.com/p/sikuli-api/" rel="noreferrer">sikuli-standalone jar</a>):</p>
  
  <pre><code># test.py
  import os
  import sys
  
  # set the classpath so java can find the code I want to work with
  sikuli_jar = '/sikuli-api.standalone-1.0.3-Pre-1.jar'
  jarpath = os.path.dirname(os.path.realpath(__file__)) + sikuli_jar
  os.environ['CLASSPATH'] = jarpath
  
  # now load a java class
  from jnius import autoclass
  API = autoclass('org.sikuli.api.API')
  </code></pre>
  
  <p>Pyisntaller creates the (<em>one folder</em>) exe with:</p>
  
  <p><code>pyinstaller -d test.py</code></p>
  
  <p>But the jar to the best of my knowledge is not bundled and is inaccessible to the exe <em>unless</em> you manually place it in the folder generated by Pyinstaller</p>
  
  <p>According to the <a href="http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html?format=raw" rel="noreferrer">Pyinstaller manual</a>: </p>
  
  <blockquote>
    <p>"CArchive contains whatever you want to stuff into it. It's very much
    like a .zip file."</p>
  </blockquote>
  
  <p>I then try editing the <em>previously auto-generated</em> <code>test.spec</code> file with:</p>
  
  <pre><code>jar = 'sikuli-api.standalone-1.0.3-Pre-1.jar'
  jar_path = 'C:\\Python27\\Lib\\site-packages\\sikuli-0.1-py2.7.egg\\sikuli\\' + jar
  coll = COLLECT(exe,
                 a.binaries,
                 a.zipfiles,
                 a.datas,
                 [('sikulijar', jar_path, 'PKG')],
                 strip=None,
                 upx=True,
                 name='test')
  </code></pre>
  
  <p>And I try building the exe based on this spec file with:</p>
  
  <pre><code>python C:\workspace\code\PyInstaller-2.1\PyInstaller\build.py --onefile test.spec
  </code></pre>
  
  <p>But nothing happens and no error returns. Can someone provide a simple step by step tutorial how this could be done? Many thanks!</p>