How can I add jars to the classpath when I invoke Jython *without* adding them to $CLASSPATH?

Hank Gay picture Hank Gay · Feb 11, 2009 · Viewed 32.5k times · Source

I'd like to do something similar to jython -cp FOO:BAR:BAZ argle.py.

If I add FOO, BAR, and BAZ to $CLASSPATH this works. I tried to add them to sys.path at run-time, but that doesn't appear to work for jars. It does work if I add a path to the expanded jars to sys.path at runtime. Is there a simple alternative to exploding the jar files? Augmenting $CLASSPATH for every user that runs this script is not an acceptable alternative.

Thanks.

Answer

awithrow picture awithrow · Feb 25, 2009

You can use the -D option to set python.path:

jython -Dpython.path=FOO:BAR:BAZ argyle.py