From: <bc...@wo...> - 2001-04-04 10:38:57
|
[Pierre Dittgen] >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.lang.ExceptionInInitializerError: java.lang.NullPointerException > at org.python.modules.os.<clinit>(os.java:11) It is a bug in the os.java module when running without an unset sys.prefix. This normally happens for jythonc compiled applications. As a workaround, you can set sys.prefix before importing the "os" module. import sys; sys.prefix = "." import os ... or you can upgrade to Jython-2.1a1 where the bug is fixed. >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 ? No. regards, finn |