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

Tomcat - removing server info

Below are the steps to remove Tomcat Server Information 1. Make sure Tomcat is not running 2. Navigate to "Tomcat Installation"...