From: Kevin M. <kev...@er...> - 2001-09-19 12:52:45
|
Hi again, I have tried for several hours now to use the extension dirs, but they don't seem to work. A small example where test2.jar tries to import a test1.jar class: test1.py: --------- class gofaster(): def __init__(self): print "Zoom" faster() Compile: -------- # jythonc -a -p com.ericsson.test1 -j test1.jar test1.py Test: ----- # java -cp test1.jar com.ericsson.test1.test1 Zoom test2.py: --------- from com.ericsson.test1 import * test1.main([""]) # <--- C style??? Compile: -------- # jythonc -a -p com.ericsson.test2 -j test2.jar test2.py MyManifest.txt: -------------- Class-Path: test1.jar Update Jar file: ---------------- # jar -umf MyManifest test2.jar Test: ----- # java -jar test2.jar Java Traceback: at org.python.core.Py.ImportError(Py.java:180) at org.python.core.imp.dottedFind(imp.java:414) at org.python.core.imp.importName(imp.java:436) at org.python.core.imp.importName(imp.java:509) at org.python.core.ImportFunction.load(__builtin__.java:967) at org.python.core.ImportFunction.__call__(__builtin__.java:961) at org.python.core.PyObject.__call__(PyObject.java:250) at org.python.core.__builtin__.__import__(__builtin__.java:921) at org.python.core.imp.importOne(imp.java:518) at com.ericsson.test1.test1$_PyInner.main$1(test1.java:36) at com.ericsson.test1.test1$_PyInner.call_function(test1.java:28) at org.python.core.PyTableCode.call(PyTableCode.java:155) at org.python.core.imp.createFromCode(imp.java:157) at org.python.core.Py.runMain(Py.java:798) at com.ericsson.test1.test1.main(test1.java:51) Traceback (innermost last): File "/home/qkename/jwork/extdirstest/test1.py", line 0, in main ImportError: No module named ericsson Environment: ------------ Everything is done in one directory. CLASSPATH is not set to anything. Using Jython 2.0 on java1.3.1 (JIT: null). Much appreciated, Kevin. On Tue, 18 Sep 2001, Samuele Pedroni wrote: > > > > > > That's a java problem/design decision. > > > > > > Java -jar ignores the classpath and limits loading > > > to the jar and the extension dirs. > > > > > > http://java.sun.com/j2se/1.3/docs/tooldocs/linux/java.html#options > > > > This webpage confirms that I can use '-cp' to set the classpath when > > running my app. > You have missed the point. It is not a matter of what the page says > about -cp but what it says about -jar: (from the vary seem page) > > > -jar > Execute a program encapsulated in a JAR file. The first argument is the name of a JAR file > instead of a startup class name. In order for this option to work, the manifest of the JAR file > must contain a line of the form Main-Class: classname. Here, classname identifies the class > having the public static void main(String[] args) method that serves as your application's > starting point. See the Jar tool reference page and the Jar trail of the Java Tutorial for > information about working with Jar files and Jar-file manifests. > > When you use this option, the JAR file is the source of all user classes, and other user class > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > path settings are ignored. > ^^^^^^^^^^^^^^^^^^^^^^^^^ > > Now you can reread my previous message. > > > > > This feels like something silly I've missed. Until now I have been trying > > to avoid having to learn about the Java environment, but there seems to be > > no helping it. > > > Avoiding to learn about the Java env and using jython is a bad > idea... > > regards, Samuele Pedroni. > _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 |