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
- File -> New -> PyDev Project (or PyModule for a single file).
- Name it, uncheck "Create a source folder" if you prefer a flat layout (or keep src/ as the source folder).
- In the interpreter step, select your registered Jython interpreter.
- Finish.
Add Jars to the Build Path
- Right-click the project -> Build Path -> Configure Build Path.
- Libraries tab -> Add External JARs (or a folder of jars via "Add Folder" + classpath variable).
- 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
- File -> Import -> PyDev -> Existing PyDev Projects.
- 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.