Jython Developer Guide / Eclipse Notes

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

Creating an Eclipse Project for Jython Development

These notes are based on configuring Eclipse 3.7 on Windows 7 in order to work as a Jython developer. There were lots of little pitfalls.

Setting up to Develop

Tools Assumed

  • Eclipse IDE for Java (SE or EE)

  • Mercurial Eclipse plug-in

Command-line versions of

  • Ant

  • Mercurial

These notes assume the tools are on your path wherever needed.

  • A version 1.6 JDK

Clone the Jython Repository

It should be possible to direct Eclipse to the on-line Jython repository at hg.python.org/jython but I prefer to do it in two stages. At C:\hg\jython-clean I have a clone of the repository created with the command-line hg (see JythonDeveloperGuide#Mercurial) that I use as a local mirror repository.

Create an Eclipse project

  1. Open Eclipse and for the sake of simplicity, close any already open projects.

  2. From the File >> New >> Project… dialogue choose Mercurial >> Clone Existing Mercurial Repository.

  3. In the Mercurial wizard, choose the Local… button and navigate to the mirror repository

  4. Choose Checkout as a project in the workspace.

  5. You can take the default directory name in your Eclipse workspace (parent directory), as you will end up with a project called “jython-trunk”.

  6. Leave Last revision blank.

  7. Press Next>. The clone can take several minutes.

  8. At the next dialogue you may choose the “branch”. These instructions assume you are developing on the default (tip).

  9. The next operation is equivalent to an hg update instruction and will populate the project with files from the repository. It may take a few minutes to execute. (If it fails with a message about the server certificate, follow the advice on Subversion and SSL in JythonDeveloperGuide.)

  10. The wizard will prompt you to import a project called “jython-trunk”. Accept this.

You should now have a project called “jython-trunk” open in your Eclipse workspace. Do not worry that the IDE reports errors. The following steps will put that right, although it gets worse before it gets better.

If you need to, this is the time to rename the project to your liking. (You may have to File >> Refresh first.)

Build it once outside the IDE

It is easiest to set up the IDE if you have already built Jython once outside the IDE. Start a command prompt in the project home (jython-trunk) directory, and issue the command ant. It is normal and harmless to get warnings from ANTLR and the javac tasks, but you should end up with “BUILD SUCCESSFUL”.

You may as well check it works. If you happen to have an environment variable JYTHON_HOME, delete it with set JYTHON_HOME=. At the command prompt then, enter

dist\bin\jython

You will see Jython cache indexes of all the JAR files it can find, then you’ll get the prompt >>>. Try a few well chosen Python commands to prove it works. The command to make it stop is exit().

Fix-up the class path in the IDE

The particulars of this section date very quickly as the selection of JAR files and their version numbers change. Enough to say that it is not unusual for the .classpath file that Eclipse uses to be out of sync with the actual JAR files in extlibs. The IDE build path (checked out by hg to file .classpath) will need changes like the following (correct around March 2012):

  1. Open Project >> Properties >> Java Build Path and from the Libraries tab remove the following:

    • extlibs/asm-3.1.jar using Remove

    • extlibs/asm-commons-3.1.jar using Remove

    • extlibs/guava-r07.jar using Remove

  2. On the Libraries tab of the same dialogue, add: