From: <bc...@wo...> - 2001-11-26 15:07:19
|
[Sebastien Pierre] >You pointed interesting things with the Java reflection. Here is what I=20= > >do: > > java -Dpython.home=3D"/sw/share/jython" -cp SPEdit.jar=20 >org.python.util.jython -v How does java find jython.jar with that command line? Is jython.jar located in the jre/lib/ext directory? It probably shouldn't be. >But when I do: > > >>> import java > >>> java.lang.Class.forName("net.sourceforge.spedit.app.Application") > >I get: >Traceback (innermost last): > File "<console>", line 1, in ? >java.lang.ClassNotFoundException: net.sourceforge.spedit.app.Application > at java.net.URLClassLoader$1.run(URLClassLoader.java:200) Since this doesn't work, there is no way jython can find the Application class (We are ignoring sys.path loading here). >Then I do: > >>> import net >import: 'net' as java package > >>> dir(net.sourceforge.spedit.app) > >and I get : >['Application', 'AuthorDisplay', 'DBView', 'NavigationTree', 'Pool',=20 >'__name__'] > >This is quite strange as I have explicitely specified the SPEdit.jar as=20= > >a classpath item...The problem is solved when I put the SPEdit.jar into=20= > >the jre/lib/ext MacOS X equivalent. > >In this case Jython has managed to index the SPEdit.jar, which is shown=20= >by the result of the dir function call, but Java itself is then unable=20= >to locate the SPEdit.jar, as if the classpath has been reset by jython. Nope, can't blame jython for this. My guess is that jython.jar exists in jre/lib/ext and that is the reason that jython can only load other code that also reside on the boot-classpath. >I have written the equivalent in Java: [...] >When I run it: >java -cp SPEdit.jar:. Test > >I get: >*sys-package-mgr*: processing new jar,=20 >'/Users/spierre/Projects/SPEdit/prototype/build/SPEdit.app/Contents/Resour= >ces/Java/SPEdit.jar' Hmm, that output can't be from your little java program. >class net.sourceforge.spedit.app.Application > >So actually Java find the class. This seems to point that the bug may be=20= >in Jython overriding in some way the class path, so that URLClassLoader=20= >is unable to find the classes anymore. regards, finn |