Defining a classpath for a Jython virtual environment
I have installed Jython, a virtualenv named "jython-env" and have installed "bottle" for doing some web application development. I have to use some JAR files in this application for consumption by some Python code. I know I have to set the classpath which should include these JAR files. I tried setting the classpath using
export classpath=/home/myname/jclasses/foo.jar
but when I try to im开发者_JAVA百科port the class, it says module not found. I am very new at Java and am doing this for the first time.
Can't the configuration be done such that I can just put the JAR files in the sitepackages directory of my virtualenv and use it from there?
jython -Dpython.path=/path/to/myjar.jar
Here's another idea: you could use a .pth
file.
Create a file - /path/to/jythonenv/Lib/site-packages/myjars.pth
:
path/to/jar1.jar
path/to/jar2.jar
Would also do the trick.
I'd like to suggest jip for you. With jip, you can manage your Java dependencies and classpath just like pip does for you.
pip install jip
Install a JAR file with dependencies,
jip install org.springframework:spring-core:3.0.5.RELEASE
Run with classpath configured,
jython-all your-python-file.py
Check http://pypi.python.org/pypi/jip for details.
精彩评论