I like Python, but I also like some Java libraries. What's an amateur (such as me) to do short of hopping on the Jython bandwagon? Embed the JVM in Python, that's what

# apt-get install python-jpype#!/usr/bin/env python
from jpype import *
startJVM('/usr/lib/jvm/java-6-openjdk/jre/lib/i386/server/libjvm.so','-ea')
java.lang.System.out.println('Hello World')
shutdownJVM()$ ./hello.py
Hello World
JVM activity report :
classes loaded : 30
JVM has been shutdown
It does add a few megs to my Python process and JNI is not exactly optimal, but this is a nice way to use Java features in Python without sacrificing Python functionality. I plan to use this the same way I work with Cython: write most of the code in Python and bits in Java when it would be beneficial.