jpype:python调用java代码

437 阅读1分钟

jvmPath = jpype.getDefaultJVMPath()

'./jars/jpype_test_new.jar' java代码jar包文件路径

jpype.startJVM(jvmPath,"-ea", "-Djava.class.path=%s" % './jars/jpype_test_new.jar')

jpype_test.Xcloudjdbc_new jpype_test:项目名 Xcloudjdbc_new:类名

Xcloudjdbc_new = jpype.JClass("jpype_test.Xcloudjdbc_new")

创建对象

xcloud = Xcloudjdbc_new()

调用方法

xcloud.func()

关闭虚拟机

jpype.shutdownJVM()