Jython Monthly


July 2006 -- Issue #1

Welcome to the first issue of Jython Monthly. The content of this newsletter will focus on using and developing the Jython languge. I hope that you are able to find some content which will interest you. I look forward to editing and distributing this newsletter monthly, and I hope you look forward to reading it.

- Josh Juneau

Questions, comments, or suggestions???

Please send email to:

jython-monthly@mchsi.com or jython-users@lists.sourceforge.net for discussion.


Standalone mode - Libraries included


Submitted by: Oti

Jython has now a standalone mode, where the core part is all included in one single jython.jar file. This has two advantages:

This really adds a Plug & Play feature to Jython.

There is a preview available (snapshot build).

A sample install and run session, after downloading jython_2837.jar:

[root@localhost downloads]# java -jar jython_2837.jar -s -d /tmp/jython_standalone -t standalone
Performing silent installation
 10 %
 20 %
 30 %
 40 %
 50 %
 60 %
 70 %
 80 %
Packing standalone jython.jar ...
 90 %
 100 %
Congratulations! You successfully installed Jython HEAD to directory /tmp/jython_standalone.

[root@localhost downloads]# cd /tmp/jython_standalone/
[root@localhost jython_standalone]# ls

[root@localhost jython_standalone]# java -jar jython.jar 
*sys-package-mgr*: processing new jar, '/tmp/jython_standalone/jython.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/rt.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/jsse.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/jce.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/charsets.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/ext/sunjce_provider.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/ext/localedata.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/ext/sunpkcs11.jar'
*sys-package-mgr*: processing new jar, '/usr/java/jre1.5.0_07/lib/ext/dnsns.jar'
Jython 2.2a1 on java1.5.0_07 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/tmp/jython_standalone/.', '/tmp/jython_standalone/./Lib', '/tmp/jython_standalone/jython.jar/Lib']
>>> import getopt

One Open issue: the cachedir problem still remains. If the directory containing jython.jar is not writable, no cachedir will help importing java classes. This is a well known problem also persistent in non-standalone mode. We try to improve this in standalone mode.

Extending on the FAQ -- Accessing your Jython code from Java and Using Reflection to Access

Extending on the Jython User FAQ section for embedding Jython, this article details the jythonc utility and possible uses.


Submitted by: Josh Juneau

Tips and Tricks

Jython Function Behavior

A useful thing to note about defining Jython functions with keyword parameters: The default values are only created once, at function compilation-time.

For instance, if the default value you’re supplying is MyClass(5, 6, 7), you might be surprised to discover that the same instance gets used with every function call.

This trick can be used to make an equivalent to C’s static local variables. Try this:

def foo(item, acc=[]):
    return acc

Now call foo a few times providing different numbers.

>>> foo(5)
>>> foo(6)
[5, 6]
>>> foo(7)
[5, 6, 7]

I’m sure there are much more interesting uses for this than my contrived little example, but you get the idea.

Source : http://oakwinter.com/code/?p=29

How to use the Wiki

Learn to use the Jython wiki for posting articles and tutorials. Help and build the Jython library! Wiki renders as html and can use css and images. It is a great tool for posting content quickly in an organized environment. Create an account and use the wiki help to get started today.


Here is an example provided by Clark Updike:

Here's the main page (rendered as HTML): http://wiki.python.org/jython/FrontPage

And here's the raw text (what had to be typed to create it): http://wiki.python.org/jython/FrontPage?action=raw


Test your skills with the Coolaps Developer Challenge: There are two ways to compete - the best application that runs on Sun Grid Compute Utility, and the best application built with the Compute Server Plugin for NetBeans. We designed things this way to allow as many people as possible to participate, including International participants, who cannot access the Sun Grid Compute Utility today.

Learn more about the Coolapps Developer Challenge: https://coolapps.developer.network.com/

Off The Lists

Pydev and Pydev Extensions 1.2.1 have been released

Details on Pydev Extensions: http://www.fabioz.com/pydev

Details on Pydev: http://pydev.sf.net

Details on its development: http://pydev.blogspot.com

Question from leouser to the community

Id like to compile a list of things that would improve Jython Shell and am curious if there are any users out there in the general Jython community that have any ideas.

I have one: Let the user alter the font from the GUI. After taking the shell to different platforms, Ive come to the conclusion that just using the supplied font is not always a good thing. Im considering adding a font chooser panel. Something at least that will let the user change the blasted font.

Any other ideas? Please send thoughts to the Jython-Users list


Interested in Developing Jython?

If you are interested in developing Jython, please take a look at the current bug listing and submit patches for items which you can repair.

Who's Using Jython?

Dojo Toolkit

The Dojo Javascript Toolkit is utilizing Jython's ANT capabilites for their build process. Take a look at this powerful toolkit...it is worth the time! http://dojotoolkit.org

Useful Links


Intro to Jython

Scripting with Jython Instead of XML


Online Jython Course


Jython Home

Python Home

Jython WikiPedia


JythonMonthly/Newsletters/July2006 (last edited 2008-11-15 09:15:57 by localhost)