Jython ImportError: No module named

importerrorjarjython

I'm new to jython and failing utterly at importing a java class within a jar.

What I am trying to do is write a wrapper shell script which calls a jython script. I can not allowed to edit the jython at all, so adding jars to sys.path within that jython script is not possible.

Error
y", line 17, in
from com.polarland.testModule.cache import CacheInterface
ImportError: No module named polarland

I've added the jar which contains the above package with name of TestModule.jar to PATH, ClASSPATH and JYTHONPATH with no avail. I'm worried this is due to the name of the jar but am not sure.

Any advice would be greatly appreciated!!

Best Answer

In your shell script use:

export CLASSPATH=TestModule.jar:$CLASSPATH
jython ...

In my case setting CLASSPATH is enough. Remember to use full path name and remember to use good .jar name (testmodule.jar and TestModul.jar are different). Maybe you use wrong file rights. Try file command to check if you can read that file. Example for one of jars I use:

mn$ file junit-4.1.jar
junit-4.1.jar: Zip archive data, at least v2.0 to extract
Related Topic