4

for python scripts i was using py2exe to create executable file. Is there any way to create either .exe or .jar file for jython script?

user19911303
  • 449
  • 2
  • 9
  • 34

2 Answers2

3

Sharing how I achieve this. Thanks to EnigmaCurry for providing the framework.

Jar Method from Jython wiki works quite well. The one drawback that it has is that all of the Java dependancies need to be exploded into the main jar root. This gets messy very quickly.

So the approach uses One-Jar. It is a special class loader which can load a jar from contained in the jar file.

So you can have your script/class, jython and other libraries all getting packaged as a single jar.

You can download the skeleton for achieving this from here.

Once you get it put your scripts in src, put the other jars (including jython jar) in the lib folder, put one-jar source in its respective folder and just run the ant tool with build.xml provided.

You will get your jar then.

Mukul Joshi
  • 324
  • 2
  • 4
0

Have you tried jump? It's a build tool for distributing Java and Jython applications. I have used it a few times before and it might be able to do what you need. It can

Distributing Jython applications into a single, independent JAR file.

Distributing Jython libraries into a single JAR file. [New in v0.9.5]

Distributing native Mac OS X application bundles, Windows .exe executables, WAR files for

Python WSGI applications. [New in v0.9.5]

Distributing Java Only applications. [New in v0.9.6]

Creating build.xml file for ant. [New in v0.9.7]

Supporting Java source code and third-party JAR files.

Supporting Java Native Interface files for distributing JAR files. [New in v0.9.5]

Starting the created distribution from either Jython or Java code.

Including specified resource files in the final distribution. [New in v0.9.6]

Packaging only required Python packages into the final distribution automatically, which means you don't have to worry about using Python third-party libraries as long as they can be found in your sys.path.

Importing specified Python packages explicitly. [New in v0.9.5]

All Python modules included in the final distribution are compiled to $py.class files, which means your source code is not public.

Integrated easy use Jython factory. [New in v0.9.7]

  • hi Anonmattymous, Thanks for your response, but i didnt get enough info about how to use this package! Can you please guide me??? – user19911303 Jun 17 '13 at 13:52
  • Try here, I dont have too much experience so this will probably help you more than I can. But if you try this and have any questions let me know. http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts#Building_jars_-_some_samples –  Jun 17 '13 at 21:35