JEP and JPype in a single process
Hello, I have written a very simple java class file, which invokes a Python script using JEP. Code snippet:- --- Jep jep = new Jep(false); jep.runScript("C:\\temp\\testscript.py"); jep.close(); Now inside this Python script I want to make Java calls using JPype. If I use startjvm() inside this Python script, a Runtime Error (exception) is thrown. Also tried attachThreadToJVM(), but doesn't work, again Runtime Error. Any clues as to how I could achieve my goal?? The interaction shown below should happen in a single process. JAVA ==> jep ==> PYTHON ==> jpype ==> JAVA Regards, skn -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating .pyo from .py
Thanks a lot !! It works fine !! regards, skn "Leif K-Brooks" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > skn wrote: > > Does the python compiler provide an option to generate a .pyo(optimized byte > > code file) from a .py (source file)? > > > > For generating .pyc I know that I only have to pass the source file name as > > an argument to py_compile.py. > > py_compile.py checks __debug__ to decide whether to use optimize mode, > and the -O option to Python turns __debug__ off, so: > > python -O py_compile.py foo.py -- http://mail.python.org/mailman/listinfo/python-list
Re: JEP and JPype in a single process
Thanks for your prompt reply, Steve. Just one suggestion, may be the startJVM method's implementation can itself be changed to check for already existing JVM. Of course this will also mean a change in shutdownJVM() semantics. If JVM has been started earlier(not using startJVM()), shutdownJVM() should be a do-nothing function. Another question I had was, is there any option to suppress the JVM activity report that gets displayed. For e.g., JVM activity report : classes loaded : 26 JVM has been shutdown I know I can do it by re-directing the std err to NUL. But is there any other option? With best regards, skn "Steve Menard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > skn wrote: > > Hello, > > > > I have written a very simple java class file, which invokes a Python script > > using JEP. > > > > Code snippet:- > > --- > > Jep jep = new Jep(false); > > jep.runScript("C:\\temp\\testscript.py"); > > jep.close(); > > > > Now inside this Python script I want to make Java calls using JPype. > > If I use startjvm() inside this Python script, a Runtime Error (exception) > > is thrown. > > Also tried attachThreadToJVM(), but doesn't work, again Runtime Error. > > > > Any clues as to how I could achieve my goal?? > > The interaction shown below should happen in a single process. > > > > JAVA ==> jep ==> PYTHON ==> jpype ==> JAVA > > > > Regards, > > skn > > > > > > You're trying to do something I hope to make possible somewhere down the > road ... > > As of today, I do not think it is possible. JPype does not provide a way > to initialize the JVM-bridge system except for startJvm .. which seems > to be prohibited when a JVM is already running. > > AttachThreadToJVM will only work once the JVM-bridge system has been > initialize. > > I will look into providing a sister method to startJVM to attach to the > currently running JVM instead of starting a new one. IF it does not > require major changes I will release it as 0.5.1. If you'd like you can > submit an enhancement request on the JPype sourceforge page, so this > doesn't get lost. > > > > -- > Steve Menard > > Maintainer of http://jpype.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
JPype - suppressing JVM activity report
Hello, Is there any option to suppress the JVM activity report that gets displayed, when you execute Java APIs from within Python using JPype. E.g., JVM activity report : classes loaded : 26 JVM has been shutdown I know I can do it by re-directing the std err to NUL. But is there any other option? -- http://mail.python.org/mailman/listinfo/python-list
Can JEP alone do the job?
Requirement == A JAVA Server(RMI Sever) has to invoke some Python scripts. These Python scripts in turn have to make some JAVA API calls. The JAVA APIs will be provided by custom Java Classes and Interfaces. I should be able to receive the "Output" from the Python script into my JAVA server. "Output" can either be:- 1) std out from Python (print statements inside Python script) OR 2) Python Objects Questions >From the initial literature study, I think I can achieve this ONLY using JEP? However I also find that there is another Integrator "JPype". My question is what do I miss if I don't use JPype? What extra does JPype have? Basically I want to avoid too many Integration technologies and use ONLY JEP (or possibly ONLY JPype.) Regards, skn -- http://mail.python.org/mailman/listinfo/python-list
Generating .pyo from .py
Hello., Does the python compiler provide an option to generate a .pyo(optimized byte code file) from a .py (source file)? For generating .pyc I know that I only have to pass the source file name as an argument to py_compile.py. But for generating .pyo, I could not find anything. Any clues/help will be greatly appreciated. With best regards, skn -- http://mail.python.org/mailman/listinfo/python-list