I have a relatively large Java application that will benefit from love in Python. To this end, I worked to launch it and run in Jython. My current checkpoint is getting the correct class path.
I applied two approaches to setting the classpath:
- Using the shell script, I created a jars list and executed
java -cp ${CP} -jar jyton.jar , where $ CP is the list of banners needed for my application. This does not seem to work. I canβt import any classes from these jars, instead I get only ImportError: No module named apache . - Using the bootstrap python script, I created a list of paths using glob and added them to the current path using
[sys.path.append(path) for path in JAR_LIST] . This seems to work correctly; Now I can import any classes I need from the included jars.
The above is a bit confusing, since most of the information I could find is aimed at using $ CLASSPATH and -cp to add your jars, but I can't get this to work. So the question is still: # 2 the correct way to add dependencies to your classpath when using Jython?
The main reason I questioned my methods is that I still have problems making full use of my application. Several places in my application respect resources using relative URLs: classpath:some-critical-file.xml
some-critical-file.xml and several of my classes are in the same jar. I can import classes from this jar, but any attempts to load my xml using classpath:some-critical-file.xml lead to java.io.FileNotFoundException
Any insight into why my classes are available, but relative resource paths using classpath: will not be very valuable. I am now at a loss.
source share