How to interact with Java from Python

I am currently using Matlab as a scientific computer language, but I am interested in moving on to a more open alternative. Python (+ scipy + numpy + matplotlib) seems like the best way. My biggest concern with the switch is that Python will not interact as good / easy / easy with Java as Matlab does, and I often have to use the Java API. In particular, I like Matlab:

1) I can instantiate Java objects and access their member variables and methods

2) Java events become “callbacks” in Matlab

3) Java types are automatically passed to Matlab types (from logical to logical, etc.)

As far as I can tell, there are 3 options in Python (see below). My concern is that each of them is supported / developed by a very small community of developers (at least 1-3 people in each case), and this support may not be forever. Which of the following does the two things that Matlab does? Most likely, this will continue in the foreseeable future? It would be a bonus if I could use the Java GUI from Python. Am I missing any options?

1) Jython

2) Py4J

3) JPype

+4
source share
1 answer

I don't think there is an easy way to do this, since SciPy and friends are currently not working on Jython. You can work as a client-server or as a subprocess with redirected standard input / output / error.

I also played with XML-RPC in one of my Python projects, I have an ad unit from documents that can be useful. You won’t get the best performance in the world along this route, but it has the advantage that you can get started easily.

0
source

All Articles