Home arrow Python arrow Page 2 - Introduction to Jython

Installing Jython - Python

Java and Python -- each have their advantages and disadvantages. What is a programmer to do if he wants ease, efficiency, and power? Believe it or not, there is a solution -- a way to merge both languages and get the best of both worlds. Read on to find out how it works.

  1. Introduction to Jython
  2. Installing Jython
  3. Calling Java Classes
  4. Embedding
By: Peyton McCullough
Rating: starstarstarstarstar / 24
February 22, 2005

print this article



Jython may be obtained from the Jython website:


Currectly, the latest version is Jython 2.1. Download it and then move to the directory where it is installed. Next, open the file with your Java interpreter. For example:

java jython-21

The installation program will be presented to you, and installing it from there should be pretty straightforward. If you're using Jython 2.1 in conjunction with Java 1.4 or later, be sure to include the source in your installation. Move to the directory where you installed Jython and open up "org/python/core/Py.java" in your favorite text editor. Replace every appearance of "assert" with "a_ssert" and ever appearance of "enum" with "e_num". Do the same with "org/python/compiler/CodeCompiler.java" and "org/python/parser/PythonGrammar.java". Note that the latter will require you to replace "e_numeration" to "Enumeration" when you are done. Jython 2.1 uses the two terms, which were set as keywords in Java 1.4.

Once you're done, move to the directory where you installed Jython and start up the Jython interactive interpreter:


If everything has gone correctly, you should see something that looks a lot like the Python interactive interpreter. Let's test it out by executing some Python code:

>>> print 'Hello World!'
Hello World!
>>> import math
>>> print math.sqrt ( 25 )
>>> someList = [ 5, 3, 4, 2 ]
>>> print someList [ 0 ]
>>> print math
(module 'math' (built-in))

As you can see, things work exactly the same as they do in Python.

>>> More Python Articles          >>> More By Peyton McCullough

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates


Dev Shed Tutorial Topics: