From: Robert W. B. <rb...@di...> - 2001-10-19 03:46:15
|
Hello Max, On Thu, 18 Oct 2001, Max Muller wrote: > Hi, > I have actually just recently gotten into jython, very cool > I must say. I am right now in the process of writing a WebObjects > framework that will allow for the use of Jython WOComponents. When > it is done I'll release the source and make an annoucement on this > list. Anyways, right now I have written a JythonClassLoader that > when given the path to a .py file it will compile the file to a > .class using jythonc and then read the .class in and construct the > Class object. So what I am wondering is it possible to not use > jythonc to compile the .class? I have been looking through the api in > the compiler package, but I haven't been able to find that magic > method. What I would really like to be able to do is in my Java app > read in the .py file and then using the Java api's of jython, compile > the .py file into a byte array (optionally write out the .class at > this point) then construct the Class object, never having to fire up > a process outside the regular vm. Anyone have any ideas? Thanks in > advance. An embedded interpreter sounds ideal for your situation, if I've understood everything correctly. You could execute a .py file in the embedded interpreter, then retrieve the class defined in that file as a Java object with the interpreter's get method. A good example of this is the org.python.util.PyServlet class that comes with Jython. More embedding info found at http://www.jython.org/docs/embedding.html -robert |