It turns out that this is possible with the Jpype and JayDeBeApi modules, however JayDeBeApi only supports Python 2. I'm looking into the best way to port it to Python 3 (it may be as simple as using distribute to automatically convert it).
Anyway, so for today:
py34 # start python 3 virtual environment
sudo apt-get install g++ python3-dev # required for Jpype installation
# make sure the jdk headers are available from your $JAVA_HOME
pip install Jpype1-py3
To test Jpype1-py3,
import jpype
jpype.startJVM(jpype.getDefaultJVMPath())
# We can now access basic JVM funcations. This took like 3 minutes to load on my system
jpype.java.lang.System.out.println("Hello from JPype!")
# since we're done we shut down the JVM
jpype.shutdownJVM()
JPype uses Java JNI to communicate to the JVM. See [1] for more info.To install JayDeBeApi I will investigate using,
from __future__ import (absolute_import, division, print_function, unicode_literals)
or putting 2to3=true in the setup/distribute config.
[1] http://jpype.sourceforge.net/doc/user-guide/userguide.html
No comments:
Post a Comment