1

I have a python application that is trying to load some Java libraries (specifically Axis2 web services). When I add the necessary jars in Eclipse via PyDev Project Source Folders, everything seems to work fine. However, I want to be able to do this at run time by adding to sys.path, but then my application doesn't seem to work.

In both cases I can load the jars just fine, but something must be different for there to be different results. My question is, is there a difference between adding jars via the sys.path at run time with sys.path.append() versus passing -D to the jython interpreter?

Bakuriu
  • 98,325
  • 22
  • 197
  • 231
trinth
  • 5,919
  • 9
  • 40
  • 45
  • Did you try to append the paths using `sys.path` and running the application outside Eclipse? Maybe it's Eclipse that is meddling something with the paths. Also try to print `sys.path` when you ran with `-D`s and when you add the paths using `sys.path.append`. – Bakuriu Nov 18 '12 at 07:51
  • @Bakuriu figured it out, see my answer below – trinth Nov 19 '12 at 20:34

1 Answers1

0

The problem turned out to be a difference in the way that Eclipse starts up the Jython interpreter as opposed to starting Jython manually from the command line. In the Eclipse Run Configuration pane, there is a way to see the command that is used to run your application. Mine looked like this:

 /usr/lib/jvm/java-7-openjdk-i386/bin/java 
   -classpath /usr/local/lib/jython2.5.3/jython.jar:... 
   org.python.util.jython 
   -Dpython.path=... 
   myScript.py

(Note: I added line breaks for readability)

So it seems that Jython is launched from Java and that the Java classpath had to be fed the paths in addition to just the python path.

trinth
  • 5,919
  • 9
  • 40
  • 45