tags:

views:

166

answers:

1

I've got a jython script that needs to include a class (from JUnit in this case). I've got the junit jar in "some/path/junit.jar". My script is:

from junit.textui import TestRunner

TestRunner.Main(["name of some class here"])

I'm running it like this:

java -cp "some/path/junit.jar" -jar jython.jar script.py

but it complains that:

    from junit.textui import TestRunner
ImportError: No module named junit

How can I make it see/import the correct class?

+2  A: 

When you use -jar option, java ignores classpath. Just run jython class directly like this,

java -cp "some/path/junit.jar:some/other/path/jython.jar" org.python.util.jython script.py

You have to love their naming convention (all lower-case class name). I assumed the class name would be Jython and it took me a few tries to figure this out.

ZZ Coder