From: Eric J. <Eri...@is...> - 2002-11-11 19:22:00
|
I'm just stuck with exactly the same problem, an interpreter that is created from within a "web start" application can't find any Java classes. The only workaround I found (and that actually works) was: interpreter = new PythonInterpreter(); interpreter.set("Entry", Entry.class); ... interpreter.exec("e = Entry()"); // OK But having over a hundred classes, this is not a really feasible solution. Any suggestions would be appreciated! -- Eric Jain |
From: Oti <oh...@ya...> - 2002-11-11 20:22:17
|
[ Eric Jain ] > I'm just stuck with exactly the same problem, an interpreter that is > created from within a "web start" application can't find any Java > classes. > > The only workaround I found (and that actually works) was: > > interpreter = new PythonInterpreter(); > interpreter.set("Entry", Entry.class); > ... > interpreter.exec("e = Entry()"); // OK > > But having over a hundred classes, this is not a really feasible > solution. > Any suggestions would be appreciated! You could try to add java packages, either from python: import sys sys.add_package("your.package") or from java (example from PyServlet.java): PySystemState sys = Py.getSystemState(); sys.add_package("javax.servlet"); sys.add_package("javax.servlet.http"); sys.add_package("javax.servlet.jsp"); sys.add_package("javax.servlet.jsp.tagext"); Best wishes, Oti. __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 |
From: Eric J. <Eri...@is...> - 2002-11-12 08:49:34
|
> You could try to add java packages, either from python: > import sys > sys.add_package("your.package") > or from java (example from PyServlet.java): > PySystemState sys = Py.getSystemState(); > sys.add_package("javax.servlet"); > sys.add_package("javax.servlet.http"); > sys.add_package("javax.servlet.jsp"); > sys.add_package("javax.servlet.jsp.tagext"); Thanks... Unfortunately neither solution seems to fix the problem completely, as the following statement doesn't seem to do anything: from org.test import * Apparently class names have to be listed explicitly: from org.test import A, B, C Which is a bit of a problem when working with a large amount of classes... -- Eric Jain |
From: Oti <oh...@ya...> - 2002-11-12 20:52:31
|
[ Eric Jain ] > > You could try to add java packages, either from python: > > import sys > > sys.add_package("your.package") > > or from java (example from PyServlet.java): > > PySystemState sys = Py.getSystemState(); > > sys.add_package("javax.servlet"); > > sys.add_package("javax.servlet.http"); > > sys.add_package("javax.servlet.jsp"); > > sys.add_package("javax.servlet.jsp.tagext"); > > Thanks... > > Unfortunately neither solution seems to fix the problem completely, > as the > following statement doesn't seem to do anything: > > from org.test import * Just don't do this if org.test is a java package. > Apparently class names have to be listed explicitly: > > from org.test import A, B, C This is the recommended way. Best wishes, Oti. __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 |
From: Eric J. <Eri...@is...> - 2002-11-18 09:30:17
|
> > from org.test import A, B, C > This is the recommended way. Just noticed another disadvantage of having to do so: This doesn't allow lazy loading of classes by Java Web Start, i.e. all classes are always downloaded, even if they are never used. -- Eric Jain |
From: Matt P. <Payne@MattPayne.org> - 2002-11-18 14:19:58
|
Quoting Eric Jain <Eri...@is...>: > > > from org.test import A, B, C > > This is the recommended way. > > Just noticed another disadvantage of having to do so: This doesn't allow > lazy loading of classes by Java Web Start, i.e. all classes are always > downloaded, even if they are never used. > Eric - I'm new to the world of http://java.sun.com/products/javawebstart/. I thougth all the jars mentioned in the <resources> section were downloaded before the program started. Then these jars become the classpath for the program. Isn't this the case? Is there a way to get jython to load needed jars from a URL at runtime? It would be great if sys.path could contain URLs.... has anyone done this? I think jython + java webstart is a combination with great potential. I haven't quite figured out how to use classes from JARs that are not in the stock jython & java distributions. Do you have examples of how to do this? My example is at http://mattpayne.org/jython/p2.jnlp (http://mattpayne.org/jython/p2_jnlp.txt to see what my XML file looks like). It's just the embedding example from Chapter 12 of Jython Essentials from ora.com. Instead of loading embed.py from the local filesystem, I load it from a URL using a simple java class. You can see all the source if you go to http://mattpayne.org/jython -Matt |
From: Eric J. <Eri...@is...> - 2002-11-19 06:24:10
|
> I thougth all the jars mentioned in the <resources> section were > downloaded before the program started. Then these jars become > the classpath for the program. Isn't this the case? <package name="org.x.*" part="a" recursive="true"/> <jar href="tools.jar" part="a" download="lazy"/> This will only download tools.jar when a class such as org.x.Y is used for the first time. Unfortunately, when running Jython from a Java application that was launched through Web Start, classes have to be imported explicitely before you can use them: PySystemState state = Py.getSystemState(); state.add_package("org.x"); from org.x import Y Which, in this case, causes tools.jar to be downloaded, even if it is never used afterwards... -- Eric Jain |