Strange Loops

No Matter Where You Go, There You Are

Compiling Jython Scripts to Java Class Files

| Comments

Had this little snippet of code lying around my directory.

Didn't know what to do with it. It was somewhat useful. We were trying to compile unit tests written in jython for our java code. The jythonc tool had gone away in jython 2.5 but an ant task (JythoncAntTask) in 2.5 still did that. I did a little bit of code spelunking and extracted the code snippet seen above. I don't know the reasons for removal of jythonc but I suspect this usage is not generally supported by the jython maintainers. Please don't complain if this doesn't work for you. We went with another approach for getting our jython unit test to run.

One should be able to compile it from the command line. You'll need the jython.jar to compile it. To run this against a jython script, I threw together a little shell script.

This post was also a little experiment in embedding code samples into my blog posts. The trick is the script tags provided by gist do not work with the preview/rich text mode provided by typepad. They only work after the blog entry has been published. Other than this little gotcha,  Gist is a nice tool for collecting code snippets.