Like the original CPython the Jython project ships with a simple command line interpreter. And, just like in CPython you can't embed the Jython interpreter in your own Java Swing application without extra work.
The CPython developers have a long history of evolving an Enhanced Python Interpreter shell called iPython.
iJython is a simple interactive Jython shell that appears to have been inspired by iPython. iJython is written in pure Java and Swing and allows you to easily embed Jython into a Java application.
You can download the source code using anonymous svn access here. We will create downloadable jar files and a java webstart version soon.
What is it good for?
We have barely scratched the surface of what can be achieved using a combination of Java and Jython. The resulting applications can use the best language for the task at hand and the end result is trivial to deploy on to all the major operating systems.
The GeoCraft application uses the shell for a few simple tasks:
- GeoCraft screenshot
- Jython manages the namespace for an object repository - see Domain Driven Design in InterestingLinks section.
- we use the Python interpreter as an expression parser.
- admittedly, Python is way over-engineered for parsing a + b but it works really well.
- Jython allows for interactive examination of the state of the Java application - debugging.
- Simple plotting functionality for data quality assurance - see JyPlot for examples.
- one day this may evolve into a more powerful data exploration tool.
Our primary interest is in making the shell a great interactive console widget that can be embedded in Java applications. This does not preclude continuing loeuser's work to replicate the iPython shell if anyone would like to contribute.
We weren't setting out to recreate iPython when we started using the jythonshell project created by leouser. The original jythonshell project seems to have disappeared and we wanted to update the jythonshell to work with the latest versions of Jython.
We are renaming the project to be iJython because there is a second jythonshell project here. We chose the name, not to goad the iPython developers :-) but because it seemed like an appropriate name for leouser's work.
The current version has been updated to compile against the Jython2.2.1 api. It has not been tested and we are not yet using it in production.
You can download the source code via anonymous svn access from svn using anonymous access. We build it and run it in Eclipse and it should be easy to use from other IDEs.
- install Jython2.2.1
- add jython.jar and junit3.8.1.jar to the path
- pass -Dpython.home=/your path to jython as a JVM argument
- if the shell complains it can't find shutil python.home is not getting set correctly
- not sure what the minimum jvm is but we are using 1.6
Our goals are fairly modest right now:
- try and simplify the code a little
- churn the apis a lot as we rename everything from jythonshell to ijython
- minor enhancements to the console
- some users don't like the color scheme
- autocomplete doesn't work for foo.bar().[what is next?]
- add the iJython project to our continuous integration builds
- generate metrics, code coverage etc.
- add some unit tests
- fix up the license so that it is the same as GeoCraft.
Leouser I would love to hear from you.