Data transfer between java and python

Sorry if my question is noob. I run Django 1.2 with pgsql 8.4, and I need to run the Java program after receiving input from the user, perform some calculations and return the results back to the user.

Can I find out what is the best way to transfer data between Java and Python Django, so the above script took care? I heard about Jython, but according to the Django docs, it requires the jython-Django extension, but it currently does not support django 1.2.x. Should I transfer data using stdout?

thanks people for listening to me.

+5
source share
4 answers

subprocess Java . , .

- , glassfish Java, Python - Java. , .

+3

, , Java , , .

JPype - , JVM Python Java, Python ().

, Jython , Java- , CPython. JPype, - Java script (aka, subprocess) .

+4

Py4J :

from py4j.java_gateway import JavaGateway
gateway = JavaGateway()                        # connect to the JVM
gateway.jvm.java.lang.System.out.println('Hello World!')

Java, Java Python.

py4j jvm, Java.

0

This may be what you wanted to avoid. but the easiest way would be to use sockets / file sharing with java. A python socket can send information and review it from java. On the other hand, if it is a sensation of pain. if you use java and python on the same computer, you can use a shared file that java can read, and python can pretend.

0
source

All Articles