JEP and JPype in a single process
Steve Menard
foo at bar.com
Mon Jun 20 16:47:24 EDT 2005
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
More information about the Python-list
mailing list