From: Garcia, M. <mg...@Bu...> - 2001-04-03 14:31:04
|
Hi Pierre, I believe you are correct. You must have the jython.jar on your delivery platform. This is not unlike trying to write servlets or some other java app. You need to have the supporting libs on the system it will run on. The jython app you are delivering is dependent on the jython distribution. Would it be possible to distribute jython with you jar? regards, Mick -----Original Message----- From: DITTGEN Pierre To: jyt...@li... Sent: 3/30/01 7:26 AM Subject: [Jython-users] Generated java classes dependency Hello, I'm quite new to jython, i find it very powerful as a script language. But at this time, I have a problem to make an independant jar from a jython script. I use Jython 2.0, with SUN JDK1.3.0 on Win2000 Pro. My script is called dir.py and contains: == begin ====== import os for file in os.listdir('.'): print file == end ======== It works well as I use the command line: jython dir.py (it shows me the list of the files of the current directory) I want to build a jar file from this script. I used this command : jythonc -a -j dir.jar dir.py It created a jar file (called dir.jar) which contains normally all the needed jython libraries needed to make it run. But as I want to run it, using the command java -jar dir.jar I got an exception : == begin ============== Java Traceback: at org.python.core.Py.JavaError(Py.java:238) at org.python.core.PyTableCode.call(PyTableCode.java:159) at org.python.core.imp.createFromCode(imp.java:157) at org.python.core.Py.runMain(Py.java:798) at dir.main(dir.java:61) Traceback (innermost last): File "C:\Documents\src\jython\test\dir.py", line 0, in main java.lang.ExceptionInInitializerError: java.lang.NullPointerException at org.python.modules.os.<clinit>(os.java:11) at java.lang.reflect.Method.invoke(Native Method) at org.python.core.PyJavaClass.initialize(PyJavaClass.java:108) at org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java:666) at org.python.core.PyClass.lookup(PyClass.java:164) at org.python.core.PyJavaClass.__findattr__(PyJavaClass.java:712) at org.python.core.PyObject.__getattr__(PyObject.java:670) at dir$_PyInner.main$1(dir.java:43) at dir$_PyInner.call_function(dir.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 dir.main(dir.java:61) java.lang.ExceptionInInitializerError: java.lang.ExceptionInInitializerError == end ================ I solved the problem giving the root dir of jython installation as a system property: java -Dpython.home=c:\dev\jython-2.0 -jar dir.jar But it annoys me... Is the generated jar (dir.jar) still dependant of the jython installation ? Does it mean that it can't run on a workstation having only JRE installed ? If not, please help me to find out the thing or the option I missed. Thanks Pierre -- Pierre Dittgen, software engineer CRIL Telecom software E-mail: pie...@cr... Phone: (33) 1 58 17 04 64 _______________________________________________ Jython-users mailing list Jyt...@li... http://lists.sourceforge.net/lists/listinfo/jython-users |
From: DITTGEN P. <pie...@cr...> - 2001-04-03 15:58:40
|
> > Hi Pierre, > I believe you are correct. You must have the jython.jar on > your delivery platform. This is not unlike trying to write > servlets or some other java app. You need to have the > supporting libs on the system it will run on. > > The jython app you are delivering is dependent on the jython > distribution. Would it be possible to distribute jython with > you jar? > > regards, > Mick > That's I would like to know... Has anyone already tried to deploy a standalone jython app (without additional Jython installation)? Thanks Pierre |
From: DITTGEN P. <pie...@cr...> - 2001-04-03 16:16:25
|
> > The code is on line 11 of os.java, which is included in your > distribution, > so you can look at the file and get an exact answer to what > failed and why. > > Ben Thanks Ben. The code at line 11 in os.java is: public static String __file__ = Py.getSystemState().prefix.toString() + "/Lib/javaos.py"; Is getSystemState() method returning a null value? Is prefix attribute null? But why, is there a reference to javaos.py? Do I need the jython libs as jython scripts (i.e. not as class files) to make my prog run? Pierre |
From: Ben H. <Ben...@fi...> - 2001-04-04 09:41:23
|
----- Original Message ----- From: "DITTGEN Pierre" <pie...@cr...> > The code at line 11 in os.java is: > > public static String __file__ = > Py.getSystemState().prefix.toString() + "/Lib/javaos.py"; > > Is getSystemState() method returning a null value? > Is prefix attribute null? Definitely one of the above. Clearly the above line sets a file path to javaos.py, presumably relative to a base JPython directory set by -Dpython.home=c:\dev\jython-2.0. When the property isnt set Jython fails. > > But why, is there a reference to javaos.py? > Do I need the jython libs as jython scripts (i.e. not as class files) > to make my prog run? My understanding is that Jython consists of both a java core interpreter and multiple modules written in python. This is a good thing: it enables Jython to provide that same Python infrastructure that CPython presents, and it tests/proves that the core interpreter is python complaint. Now this means that your app will have to ship some python files in the JAR. They are too big so this shouldnt be a problem. You just need to devise a way to set 'python.home' in your deployment. What you want is an absolute URL to the JAR you are packed in, on the host machine, because the location of .py files is fixed and relative to that. I dont know if anyone has already solved this one finally for Jython. What I would do is use the *useful* Classloader.getSystemResource(String resource) method. This can take the relative name of a file, which it will search for in all the roots of its classpath, and return you an absolute URL locating the file. Additionally, you could look at Bruce Eckels "Thinking in Patterns", which is free online and has some useful advanced Jython examples in the Interpreter chapter. Regards Ben |
From: DITTGEN P. <pie...@cr...> - 2001-04-04 10:02:57
|
> > Now this means that your app will have to ship some python > files in the JAR. It annoyed me quite much and I looked further in the code (in org.python.modules.os). Before the line that causes me trouble, i.e. this: public static String __file__ = Py.getSystemState().prefix.toString() + "/Lib/javaos.py"; there is a comment saying: // An ugly hack, but it keeps the site.py from CPython2.0 happy So, apparently, it's just a hack, that's not used at runtime... BUT, this hack requires the 'python.home' system property to be set.. So, i just tried to declare it and it works! my example runs now with: java -Dpython.home= -jar dir.jar (dir.jar was created using --all option to include all jython libs useful for my app) It won't be very difficult to set this empty property at deployment time, in any case easier than installing a jython distrib on the host machine. Thanks for the help Pierre |
From: Ben H. <Ben...@fi...> - 2001-04-03 16:03:24
|
The stack trace shows that the jython library was present. Consider the evidence: > java.lang.ExceptionInInitializerError: java.lang.NullPointerException > at org.python.modules.os.<clinit>(os.java:11) ExceptionInInitializerError means that some code running when the 'os' class loaded into the JVM, (possibly in a "static{}" code block), threw a null pointer exception. The code is on line 11 of os.java, which is included in your distribution, so you can look at the file and get an exact answer to what failed and why. Ben ----- Original Message ----- From: "Garcia, Michael" <mg...@Bu...> To: "'DITTGEN Pierre '" <pie...@cr...>; <jyt...@li...> Sent: Tuesday, April 03, 2001 3:23 PM Subject: RE: [Jython-users] Generated java classes dependency > Hi Pierre, > I believe you are correct. You must have the jython.jar on your delivery > platform. This is not unlike trying to write servlets or some other java > app. You need to have the supporting libs on the system it will run on. > > The jython app you are delivering is dependent on the jython distribution. > Would it be possible to distribute jython with you jar? > > regards, > Mick > > -----Original Message----- > From: DITTGEN Pierre > To: jyt...@li... > Sent: 3/30/01 7:26 AM > Subject: [Jython-users] Generated java classes dependency > > Hello, > > I'm quite new to jython, i find it very powerful as a script language. > But at this time, I have a problem to make an independant jar from a > jython > script. > I use Jython 2.0, with SUN JDK1.3.0 on Win2000 Pro. > > My script is called dir.py and contains: > == begin ====== > import os > > for file in os.listdir('.'): > print file > == end ======== > > It works well as I use the command line: > jython dir.py > (it shows me the list of the files of the current directory) > > I want to build a jar file from this script. > I used this command : > jythonc -a -j dir.jar dir.py > It created a jar file (called dir.jar) which contains normally all the > needed jython libraries > needed to make it run. > But as I want to run it, using the command > java -jar dir.jar > I got an exception : > == begin ============== > Java Traceback: > > at org.python.core.Py.JavaError(Py.java:238) > at org.python.core.PyTableCode.call(PyTableCode.java:159) > at org.python.core.imp.createFromCode(imp.java:157) > at org.python.core.Py.runMain(Py.java:798) > at dir.main(dir.java:61) > Traceback (innermost last): > File "C:\Documents\src\jython\test\dir.py", line 0, in main > java.lang.ExceptionInInitializerError: java.lang.NullPointerException > at org.python.modules.os.<clinit>(os.java:11) > at java.lang.reflect.Method.invoke(Native Method) > at org.python.core.PyJavaClass.initialize(PyJavaClass.java:108) > at > org.python.core.PyJavaClass.lookupGivingClass(PyJavaClass.java:666) > at org.python.core.PyClass.lookup(PyClass.java:164) > at > org.python.core.PyJavaClass.__findattr__(PyJavaClass.java:712) > at org.python.core.PyObject.__getattr__(PyObject.java:670) > at dir$_PyInner.main$1(dir.java:43) > at dir$_PyInner.call_function(dir.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 dir.main(dir.java:61) > > java.lang.ExceptionInInitializerError: > java.lang.ExceptionInInitializerError > == end ================ > > I solved the problem giving the root dir of jython installation as a > system > property: > java -Dpython.home=c:\dev\jython-2.0 -jar dir.jar > > But it annoys me... > Is the generated jar (dir.jar) still dependant of the jython > installation ? > Does it mean that it can't run on a workstation having only JRE > installed ? > If not, please help me to find out the thing or the option I missed. > > Thanks > Pierre > -- > Pierre Dittgen, software engineer > CRIL Telecom software > E-mail: pie...@cr... > Phone: (33) 1 58 17 04 64 > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > http://lists.sourceforge.net/lists/listinfo/jython-users > > |