home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Previous Section Next Section

2.3 Installing Jython

To install Jython, you need a Java Virtual Machine (JVM) that complies with Java 1.1 or higher. See http://www.jython.org/platform.html for advice on JVMs for your platform.

To download Jython, visit http://www.jython.org and follow the link labeled Download. The latest version at the time of this writing is:

http://prdownloads.sf.net/jython/jython-21.class

In the following section, for clarity, I assume you have created a new directory named C:\Jy and downloaded jython-21.class there. Of course, you can choose to name and place the directory as it best suits you. On Unix-like platforms, in particular, the directory name will more likely be something like ~/Jy.

The Jython installer .class file is a self-installing program. Open an MS-DOS Prompt window (or a shell prompt on a Unix-like platform), change directory to C:\Jy, and run your Java interpreter on the Jython installer. Make sure to include directory C:\Jy in the Java CLASSPATH. With most releases of Sun's Java Development Kit (JDK), for example, you can run:

C:\Jy> java -cp . jython-21

This runs a GUI installer that lets you choose destination directory and options. If you want to avoid the GUI, you can use the -o switch on the command line. The switch lets you specify the installation directory and options directly on the command line. For example:

C:\Jy> java -cp . jython-21 -o C:\Jython-2.1 demo lib source

installs Jython, with all optional components (demos, libraries, and source code), in directory C:\Jython-2.1. The Jython installation builds two small, useful command files. One, run as jython (named jython.bat on Windows), runs the interpreter. The other, run as jythonc, compiles Python source into JVM bytecode. You can add the Jython installation directory to your PATH, or copy these command files into any directory on your PATH.

You may want to use Jython with different JDKs on the same machine. For example, while JDK 1.4 is best for most development, you may also need to use JDK 1.1 occasionally in order to compile applets that can run on browsers that support only Java 1.1. In such cases, you could share a single Jython installation among multiple JVMs. However, to avoid confusion and accidents, I suggest you perform separate installations from the same Jython download on each JVM you want to support. Suppose, for example, that you have JDK 1.4 installed in C:\Jdk14 and JDK 1.1 installed in C:\Jdk11. In this case, you could use the commands:

C:\Jy> \Jdk14\java -cp . jython-21 -o C:\Jy21-14 demo lib source
C:\Jy> \Jdk11\java -cp . jython-21 -o C:\Jy21-11 demo lib source

With these installations, you could then choose to work off C:\Jy21-14 most of the time (e.g., by placing it in your PATH), and cd to C:\Jy21-11 when you specifically need to compile applets with JDK 1.1.

    Previous Section Next Section