I am trying to package a jython program into a jar which the user can simply double-click to run without installing jython ahead of time. Ultimately I would like to include an additional library which I wrote with the jar, but at the moment I am just trying to package a simple program and have it run from the jar.

I have tried following the jar instructions in the "Using the Jar Method" section here: http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts#Using_the_Jar_Method

I have also looked at slides 25-28 here: http://www.slideshare.net/fwierzbicki/jython-update-2012#

And finally here:

I have installed jython 2.5.3, jvm 1.6, and python 2.7.3 on my mac which is running OS X 10.8.3.

These are the steps I go through to create the jar and run it:

1. Create a copy of jython.jar from my jython installation directory.
2. zip -r jython_copy.jar Lib (where Lib is the folder in the jython installation directory)
3. cp myJythonProgram.py __run__.py (myJythonProgram.py does not include an 'if __name__ == __main__' line)
4. zip jython_copy.jar __run__.py
5. export CLASSPATH=/path/to/my/app/jython_copy.jar:$CLASSPATH

I have tried running the jar using all three of these methods:

1. java org.python.util.jython -jar myapp.jar
2. java -cp myapp.jar org.python.util.jython -jar myapp.jar
3. java -jar myapp.jar -jar myapp.jar

This works if my program doesn't use any include statements.

However I am running into an issue where certain python packages are not able to be found when I run the jar. For instance, I get the error "ImportError: No module named random" when I include the line "from random import random" in my program. No errors occur on lines in the program when I import from javax.swing, java.awt, time, or math.

I tried to package a jar with my library using the following additional steps:
1. zip jython_copy.jar myLibrary.jar
2. java ufm jython_copy.jar othermanifest.mf

othermanifest.mf only contains the line "Class-Path: ./myLibrary.jar".

This too gives the error "ImportError: No module named myLibrary" 

I would appreciate any insight into what I am doing incorrectly or other steps I should take.