Appendix A. Installing Jython on Windows

CONTENTS
  •  Installing Java Runtime
  •  Installing the J2SE Step by Step
  •  Installing Jython

First we'll install J2SE v.1.4, because it's the most recent version available as I write. Then we'll install the latest version of Jython.

Before we start, let's get something straight. You might very well have trouble installing Jython because of the number of steps involved. You may need an expert computer configurator to help you with your Jython installation. This might be a computer technician or programmer, or it might even be that kid next door who's always making bootleg floppies so he can play the latest games.

If your local expert fails you, visit the newsgroups for Java and Python. They're usually willing to help new programmers. Just check out the newsgroup's FAQs (frequently asked questions) first to avoid looking stupid.

Installing Java Runtime

Before you can use the Jython interactive interpreter, you need a Java development tool or Java runtime environment. The Java Developers Kit (J2SE) is free and, as the reference implementation for Java, is the logical choice, especially for beginners (all of the examples in the book use Jython in conjunction with the J2SE). The J2SE's latest version is available at the Javasoft Web site.

Even though I use the J2SE, I should say that Microsoft's free Java Virtual Machine (JVM) has some features that make it a good alternative with Windows. In particular, it streamlines the installation of Java packages and allows integration with ActiveX and Windows API via JDirect. Visit Microsoft's Web site for downloading instructions.

One more thing before we get started. All of the examples in the book were created on a Microsoft Windows 98 system, and the references are specific to Windows 98 users (although they should work equally well with Windows 95 and sometimes Windows NT v.4.0). I chose Windows primarily because I'm a recovering Microsoft lackey but also because it would be impossible to document J2SE and Python set up on all of the systems for which they're available. I had to choose something, and Windows was it.

I will, however, show you Jython configuration and installation on Linux systems. I figure that if you have a UNIX/Linux background, you're smart enough to translate from DOS to UNIX (or, for that matter, from DOS to Mac).

If you're not a Windows or Linux user, go to the platform.html page at the Python Web site (www.jython.org) for JVM installation instructions. Check out the links to pages specific to your platform.

Installing the J2SE Step by Step

Before you can start installation, you need to download and install J2SE v.1.4 (or the equivalent for your environment; Linux users, see Appendix B). Just follow the instructions at http://java.sun.com/products/jdk/1.4/. This can take a while depending on your modem's speed. Once you have the J2SE, install the software by double-clicking the file in the directory you downloaded it to.

During setup, accept all defaults. For example, the default directory is C:\j2skd1.4.0. The rest of the instructions assume that you've put the file there.

If the J2SE Won't Start

Be sure you saved it with an *.exe file extension, which tells Windows that the file is binary executable.

Startup

Once installation is complete, edit your c:\autoexec.bat file with your text editor. This file usually has Windows and DOS startup information. Make sure that the PATH environment variable contains the J2SE1.4 bin directory. Windows uses PATH to find executable programs. It gives you convenient access to Java, the Java interpreter, Javac, the Java compiler, and other Java tools, which will come in handy as you do the exercises.

For Windows 95, Windows 98, and Windows ME, add the CLASSPATH environment variable to autoexec.bat after the PATH statement. This tells Java, the interpreter, and Javac where to find Java classes.

REM ********* settings for J2SE ***************** SET PATH=%PATH%;C:\j2se1.3\bin; SET CLASSPATH=.

Notice that CLASSPATH is set to '.', which means the current directory. If there's already a CLASSPATH statement, make sure a period is specified.

For Windows NT4.0:

  1. Go to the Start menu and then the Settings menu. Select Control Panel.

  2. In the control panel, double-click the System icon.

  3. In the Systems Option dialog box, choose the Environment tab.

  4. Edit the PATH environment variable by adding C:\j2skd1.4.0\bin to the search path.

  5. Use the same technique to edit the CLASSPATH variable.

For Windows 2000:

  1. Go to the Start menu and then the Settings menu; Select Control Panel.

  2. In the control panel, double-click the System icon.

  3. In the Systems Properties dialog box, choose the Advanced tab.

  4. In the Advanced tab, hit the Environment Variables button.

  5. Edit the PATH environmental variable by adding C:\j2skd1.4.0\bin to the search path.

  6. Use the same technique to edit the CLASSPATH variable.

A Little Tip

Before you add the directory to the PATH statement, make sure there are no older versions of the J2SE already there. If there are, they'll be executed instead of C:\j2se\1.3.

Once you've installed the J2SE and edited the autoexec.bat file, reboot your PC. Then, to test that everything is okay, go to the DOS prompt, and enter java version at the command line. You should see the following:

c:\java-version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

Troubleshooting

If you don't see the okay message, type c:\j2skd1.4.0\bin\java at the DOS prompt.

C:\> c:\j2sjd1.4.0\bin\java -version java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

If this works, you have a problem with your PATH statement. Try entering PATH at the command line to see what it looks like. Probably you have a typo or you forgot to reboot (autoexec.bat runs only after rebooting).

If you still don't see the okay message and all you're getting is "Bad command or filename," then your setup program didn't work. You may have put the J2SE in the wrong directory. Go to the Start menu and then Find Files or Folders, and look for java.exe. This should tell you where you installed the J2SE or if you actually installed it. If all else fails, it's time to call in an expert configurator.

Installing Jython

Jython is free and open source. All you have to do is go to http://www.jython.org/download.html and do what you're told. (Jython is the latest Python release.)

Jython is backward compatible with JPython (in which all of the examples are written), so feel free to use it. Just make sure to type jython instead of jython in the interpreter and jythonc instead of jythonc in the compiler.

To install Jython, go to the directory where it's downloaded and type java jython-20 at the DOS prompt.

C:\temp> java jython-20

Note that a Java class name does not end with a .class extension, so leave it off.

While the setup program executes, read and accept the license agreement.

Startup

Once the setup is complete, edit the autoexec.bat file to access the Jython interpreter. Open the file with a text editor, and add the following lines after those entered for the J2SE.

For Jython:

REM ********* settings for Jython ***************** SET PATH=%PATH%;C:\Jython SET CLASSPATH=%CLASSPATH%;C:\Jython.jar

The PATH statement tells Windows to append c:\Jython to the PATH environment variable, which holds the file's executable search path for Windows. The CLASSPATH statement enables the Java interpreter to find the Jython class libraries.

At this point you should be able to run Jython by entering Jython at the command-line DOS prompt. More installation information is available at www.jython.org/installhtml.

Jython doesn't come with all of the standard Python modules, but you can download them from www.jython.org/download.html and follow the installation instructions.

Installation Tip

If you have any problems with installation, report them to jython-dev@lists.source-forge.net. (Tell them I sent you.) Make sure you've done everything you can before reporting what might turn out to be a nonproblem. You may discover that your problem is unique to your platform. To find out for sure, go to www.jython.org/platform.html. They'll let you know.

To run your downloaded file, go to the directory that holds the Python library file, and run this at the command line:

C:\temp> jython -jar pylib152a.jar

Done at last. If you've come this far, you can call yourself a master configurator. Nothing can stop you from learning Python.

CONTENTS


Python Programming with the JavaT Class Libraries. A Tutorial for Building Web and Enterprise Applications with Jython
Python Programming with the Javaв„ў Class Libraries: A Tutorial for Building Web and Enterprise Applications with Jython
ISBN: 0201616165
EAN: 2147483647
Year: 2001
Pages: 25

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net