Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Intro to Jython, Part 1: Java programming made easier

Barry Feigenbaum, Sr. Consulting IT Architect, IBM

Dr. Barry Feigenbaum is a member of the IBM Worldwide Accessibility Center, where he is part of team that helps IBM make its own products accessible to people with disabilities. Dr. Feigenbaum has published several books and articles, holds several patents, and has spoken at industry conferences such as JavaOne. He serves as an Adjunct Assistant Professor of Computer Science at the University of Texas, Austin.

Dr. Feigenbaum has more than 10 years of experience using object-oriented languages like C++, Smalltalk, the Java programming language, and Jython. He uses the Java language and Jython frequently in his work. Dr. Feigenbaum is a Sun Certified Java Programmer, Developer, and Architect.


Acknowledgements

I would like to acknowledge Mike Squillace and Roy Feigel for their excellent technical reviews of this tutorial.

Summary:  This is the first in a two-part tutorial that will introduce you to the Jython scripting language and provide you with enough knowledge to begin developing your own Jython-based applications. In this first half of the tutorial, you'll learn the concepts and programming basics of working with Jython, including access options and file compilation, syntax and data types, program structure, procedural statements, and functions.

Date:  08 Apr 2004
Level:  Introductory PDF:  A4 and Letter (1165 KB | 65 pages)Get Adobe® Reader®

Activity:  85999 views
Comments:  

Getting started

Installation instructions

In this section we'll walk through each of the steps for downloading, installing, and verifying Jython on your development system.

Download Jython

You can download Jython 2.1 from the Jython home page. You'll find easy-to-follow download instructions on the download page.

As previously mentioned, this tutorial is based on the current stable Jython level, which is version 2.1. More advanced development levels may also be available from the Jython home page.

Install Jython

Installing Jython is simple: just execute the class file you've downloaded from the Jython homepage. Assuming that you have a JRE installed and have the downloaded class file in your current directory (C:\ in the examples below) the following command will install Jython (note that <java_home> is the directory the JRE is installed in):

C:\><java_home>\bin\java jython-21

Please follow the install application's prompts. I recommend you select the defaults, and that you select c:\Jython-2.1 as the destination directory.


Verify the install

To verify that Jython is installed, enter the command:

C:\>dir c:\Jython-2.1

The result should be a listing like this one:

  Volume in drive C is C_DRIVE
  Volume Serial Number is ????-????

  Directory of C:\Jython-2.1

--/--/----  --:---      <DIR>          .
--/--/----  --:---      <DIR>          ..
--/--/----  --:---               1,873 ACKNOWLEDGMENTS
--/--/----  --:---      <DIR>          cachedir
--/--/----  --:---      <DIR>          com
--/--/----  --:---      <DIR>          Demo
--/--/----  --:---      <DIR>          Doc
--/--/----  --:---      <DIR>          installer
--/--/----  --:---                 428 jython.bat
--/--/----  --:---             719,950 jython.jar
--/--/----  --:---                 272 jythonc.bat
--/--/----  --:---      <DIR>          Lib
--/--/----  --:---               7,184 LICENSE.txt
--/--/----  --:---              18,178 NEWS
--/--/----  --:---      <DIR>          org
--/--/----  --:---                 651 README.txt
--/--/----  --:---               4,958 registry
--/--/----  --:---      <DIR>          Tools
--/--/----  --:---             224,493 Uninstall.class
                9 File(s)        977,987 bytes
               ? Dir(s)   ??? bytes free



A test run

The final step is to ensure that Jython is configured. To run Jython, start by entering the command:

C:\>c:\jython-2.1\jython

The command should result in an introduction similar to this one:

Jython 2.1 on java1.4.1_01 (JIT: null)
Type "copyright", "credits" or "license" for more information.

Finally, we'll exit Jython. At the Jython prompt, enter the following command:

>>> import sys; sys.exit()

Alternatively, you could just press Ctrl+C two times.


Making life more convenient

There is just one last thing you should know before we close this section on getting started. You can eliminate the need to specify the Jython command path (<d>:\jython-2.1) by adding it to your PATH variable. Now you can just type jython at the command prompt.

2 of 16 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=131933
TutorialTitle=Intro to Jython, Part 1: Java programming made easier
publish-date=04082004
author1-email=feigenba@us.ibm.com
author1-email-cc=jaloi@us.ibm.com