JPython: The Felicitous Union of Python and Java

JPython is a recently released version of Python written entirely in Java by Jim Hugunin. JPython is a very exciting development for both the Python community and the Java community. Python users are happy that their current Python knowledge can transfer to Java-based development environments; Java programmers are happy that they can use the Python scripting language as a way to control their Java systems, test libraries, and learn about Java libraries from an interpreted environment.

JPython is available from http://www.python.org/jpython, with license and distribution terms similar to those of CPython (which is what the reference implementation of Python is called when contrasted with JPython).

The JPython installation includes several parts:

  • jpython: The equivalent of the Python program used throughout the book.

  • jpythonc: Takes a JPython program and compiles it to Java class files. The resulting Java class files can be used as any Java class file can, for example as applets, as servlets, or as beans.

  • A set of modules that provide the JPython user with the vast majority of the modules in the standard Python library.

  • A few programs demonstrating various aspects of JPython programming.

Using JPython is very similar to using Python:

~/book> jpython
JPython 1.0.3 on java1.2beta4
Copyright 1997-1998 Corporation for National Research Initiatives
>>> 2 + 3
5

In fact, JPython works almost identically to CPython. For an up-to-date listing of ...

Get Learning Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.