Home | www.python.org
Download | Documentation

Documentation
Overview
Executive Summary
Invoking Jython
Jython Registry
Embedding
Compiling Jython from source
Working with Java
The Basics
JavaBean Properties
Java arrays
Subclassing
Building applets, servlets, beans...
Reloading java classes
zxJDBC
Python Docs (exits)
Python Tutorial
Library Reference
Other
Jython vs. CPython
Jython FAQ (exit)
List Archives (exit)
JPython paper (exit)
Email Us
jython-dev@lists.sourceforge.net

### Compiling Jython

Most users of Jython will never be required to look at the contents of the source directories, or try and recompile any of the files in the org.python package. All of these files have been precompiled in jython.jar.

For those people who do want to rebuild Jython from the source, for whatever reason, the following offers a few tips to keep in mind.

- The source directories from CVS or the nightly buils contain both makefiles and a build.xml file. Only the build.xml is updated at this time. We are using ant-1.2 to compile the sources and create the .jar file.

  The build.xml file will search for a properties file called `ant.properties` which can contain values to control paths and local options. My `ant.properties` file look like this:

  >     # javaccHome2 is needed when making modification to the grammar.
  >     javaccHome2 = d:\\java\\Javacc2.0\\bin\\lib

  >     # PyXmlHome is needed when running the installXML ant task to
  >     # copy PyXML files to jython.
  >     PyXmlHome = d:\\python\\PyXML-0.6.6

  >     #build.compiler = classic
  >     build.compiler = jikes
  >     debug=on

  >     # python.home is needed when building the documentation and installing
  >     # PyXML sources.
  >     python.home=d:\\python\\python211

  >     # Needed when building documentation.
  >     ht2html.dir=d:\\jython\\ht2html-1.1
  >     jython.home=d:\\jython\\CVS

  >     # Needed when installing documentation.
  >     scp.command=scp
  >     scp.user=bckfnn

  >     # Needed for building PyServlet support.
  >     servlet.jar=d:/java/servlet/servlet.jar

  >     # Needed for building Readline support.
  >     readline.jar=d:/java/java_readline-0.6/java_readline.jar

  >     # Needed for building zxJDBC DataHandlers
  >     # If missing, the appropriate DataHandler will not be built
  >     oracle.jar=d:/java/lib/classes12.zip
  >     mysql.jar=d:/java/lib/mm.mysql-2.0.6.jar
  >     informix.jar=d:/java/lib/ifxjdbc.jar;d:/java/lib/ifxjdbcx.jar
  >     postgresql.jar=d:/java/lib/postgresql.jar
  >     jdbc.jar=d:/java/lib/jdbc2_0-stdext.jar

- Some of the sources in the org.python.parser package are generated from python.jtt file by the JavaCC parser generator. If you need to make changes to the grammar file you will need to download this JavaCC. The generated files are also in the distribution, so usually this is not necessary.

  To regenerate the parser from the grammar, run jjtree on python.jjt, and then run javacc on the resulting python.jj. This should produce all of the required source files to build the org.python.parser package. The build.xml file already contain the needed entries to run the JavaCC program when the python.jjt is modified.

- The source directories contain several files that require Java2. These files are normally easily recoqnizable because they have the number "2" in their name.

  When compiling jython with Java1 compiler (like the JDK1.1), these java2 files can be safely ignored. Jython will work even when these classes files are missing. The build.xml file have a conditional check and will not try to compile the Java2 sources when using a Java1 compiler.

- One of the sources depends on the servlet classes and can only compile when servlet.jar is included on the classpath. Again, the build.xml have a conditional check and will not compile the PyServlet class if the servlet classes isn't available during compilation.

- The CVS only contain a few of the standard python modules. The rest most come from a CPython installation. Setting this up can be performed by creating a file ".jython" in your home directory and including a line like this:

  >     python.path=d:\\python\\Python-2.1\\Lib

- The PyXML sources (the content of ./Lib/xml) is not included in the CVS repository. This is mainly because PyXML is developed and released in its own time cycle. To install PyXML support in a CVS version, the ant properties `PyXmlHome` and `python.home` must be configured and the ant task `installXML` must be executed.

If you have further interest in the Jython source and Jython's continued development, you can read the archives for the Jython-dev mailing list or you can join the list.

Suggested tools and support software:

- JavaCC 2.0
- Ant
- Servlet classes
- MySQL JDBC Driver
- Informix JDBC Driver
- Postgresql JDBC Driver
- Oracle JDBC Driver