|
[Jython-users] CLASSPATH and imports question
From: Polly Powledge <pollyp@gm...> - 2008-04-11 18:09
|
Hi, I'm preparing my jython application for distribution, and I've run into a couple of classpath-related quirks. I've got a workaround, but I'm hoping someone can enlighten me about what's going on. I looked at the Distributing Jython FAQ at: http://wiki.python.org/jython/JythonFaq/DistributingJythonScripts, and I'm trying to duplicate the suggested classpath method. To that end, I installed the jython standalone jar, and then tried to run it at my command line: desktop:~/jython2.2.1Standalone> java -cp ./jython.jar org.python.util.jython Jython 2.2.1 on java1.5.0_10 Type "copyright", "credits" or "license" for more information. >>> So far, so good. But the first thing that surprised me was that even though I've supplied the standalone jar as a java parameter, to get at Java classes, I need to set the CLASSPATH environment to the same jarfile. Either setting CLASSPATH in the shell and exporting it or setting it in the interpreter works. I would have thought setting the command line option would have been enough. The second thing is that even with the CLASSPATH set, I still can't import groups of javax.classes: >>> import javax.swing Traceback (innermost last): File "<console>", line 1, in ? ImportError: no module named javax >>> But what I can do is import a specific class, and once I do that, I can import groups of classes: >>> import javax.swing.JFrame >>> import javax.swing >>> I have the same problem with third party jar files, e.g. jdom. Everything works fine when I use jython directly: desktop:~/jython2.2.1Standalone> jython *sys-package-mgr*: processing new jar, '/home/pollyp/jython2.2.1Standalone/jython.jar' Jython 2.2.1 on java1.5.0_10 Type "copyright", "credits" or "license" for more information. >>> import javax.swing >>> Any thoughts about why I'm seeing this behavior? Many thanks, Polly |
| Thread | Author | Date |
|---|---|---|
| [Jython-users] CLASSPATH and imports question | Polly Powledge <pollyp@gm...> |