小编Has*_*sti的帖子

如何从java类调用python方法?

我在Java项目中使用Jython.

我有一个Java类:myJavaClass.java和一个Python类:myPythonClass.py

public class myJavaClass{
    public String myMethod() {
        PythonInterpreter interpreter = new PythonInterpreter();
        //Code to write
    }
 }
Run Code Online (Sandbox Code Playgroud)

Python文件如下:

class myPythonClass:
    def abc(self):
        print "calling abc"
        tmpb = {}
        tmpb = {'status' : 'SUCCESS'}
        return tmpb
Run Code Online (Sandbox Code Playgroud)

现在问题是我想abc()myMethod我的Java文件的方法调用我的Python文件的方法并打印结果.

python java methods jython

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

jython ×1

methods ×1

python ×1