Wednesday, February 9, 2011

Jython - Simple Setup and Example

Jython ( is a Python for Java project. It is useful for people who want to run Python code in JVM.

Here is to teach you some simple set up.

1. Make sure you download latest Jython at When I post this, the latest version is 2.5.3.RC3

2. The 2 most important file in the download is jython.jar and the Lib folder. jython.jar only provide a small implementation of Python functions, see Thus, you have to include the provided Lib folder. As long as the Lib folder exist along jython.jar, you can import the provided Python libraries. For example, "from re import *" to import Python regular expression library.

3. Write your own Python code with .py extension

4. Then, you can run this Python code with Java by calling

java -cp "jython.jar" org.python.util.jython

No comments:

Post a Comment

Facebook - Control privacy setting of liked page

By default, Facebook displayed your liked page to public. It is the user responsibility to adjust the privacy setting. And in my opinion, F...