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 |