Skillversitas

Creating a Jython Project in Eclipse

A Jython project in Eclipse is a PyDev project configured with the Jython interpreter, a source directory for .py files, and a build path of Java jars. This chapter walks the project creation end to end, so the result runs, debugs, and organizes cleanly from day one.

Create the Project

  1. File -> New -> PyDev Project (or PyModule for a single file).
  2. Name it, uncheck "Create a source folder" if you prefer a flat layout (or keep src/ as the source folder).
  3. In the interpreter step, select your registered Jython interpreter.
  4. Finish.

Add Jars to the Build Path

  1. Right-click the project -> Build Path -> Configure Build Path.
  2. Libraries tab -> Add External JARs (or a folder of jars via "Add Folder" + classpath variable).
  3. Apply - the editor now resolves your java.* imports against those jars.

A Sensible Structure

MyJythonProject/
  src/
    main.py          # entry point
    myapp/
      __init__.py
      gui.py
      service.py
  lib/
    common.jar
    net.jar
  README.md
# src/main.py
from myapp.gui import MainFrame

def main():
    MainFrame().show()

if __name__ == "__main__":
    main()

Run and Debug

  • Right-click main.py -> Run As -> PyDev/Jython Run - executes with the project's interpreter and build path.
  • Debug As gives breakpoints and a variables view; set a breakpoint in gui.py and step through the event handlers.
  • For Swing apps, the debugger and the EDT coexist fine; just do not block the EDT in your code.

Version Control

  • Team -> Share Project -> Git (or SVN) to put the project under VCS.
  • Ignore lib/ jars if they come from a package manager or are committed elsewhere; commit a libraries manifest instead.

Importing an Existing Project

  1. File -> Import -> PyDev -> Existing PyDev Projects.
  2. Point at the directory with the .project file (or create the project from the folder and re-point the interpreter to Jython).

Summary

Create a Jython project in Eclipse as a PyDev project bound to the Jython interpreter, give it a src/ package layout, add your jars to the build path so java.* imports resolve, and use Run/Debug As for execution and breakpoints. The same project tools (VCS, shared libraries) work as in any Python project.