5

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 import 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?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
rubicondude
  • 605
  • 2
  • 7
  • 10

2 Answers2

6
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.

jsw
  • 2,173
  • 2
  • 13
  • 14
3

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ning Sun
  • 2,145
  • 1
  • 19
  • 24