passing data between java and python

前端 未结 4 853
天命终不由人
天命终不由人 2021-01-03 02:17

Apologies if my question is noob. I\'m running Django 1.2 with pgsql 8.4 and I\'m required to run a Java program after getting the inputs from the user, does some calculatio

4条回答
  •  春和景丽
    2021-01-03 02:41

    You can also use Py4J for this task:

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

    You should first start the Java program, and then invoke Java method from Python.

    py4j doesn't start jvm, it just connects to the already started Java process.

提交回复
热议问题