python调用java代码jar包

jarpath = os.path.join(os.path.abspath('.'), 'D:/apache-jmeter-3.3/jarfiles/99bill_QA_TA_FO_Interface.jar')
dependency = os.path.join(os.path.abspath('.'), 'D:/apache-jmeter-3.3/jarfiles/dependency')
jpype.startJVM("C:/Program Files/Java/jre1.8.0_181/bin/server/jvm.dll", "-ea", "-Djava.class.path=%s" %jarpath)    
#当有依赖的JAR包存在时,一定要使用-Djava.ext.dirs参数进行引入
#jpype.startJVM("C:/Program Files/Java/jre1.8.0_181/bin/server/jvm.dll", "-ea", "-Djava.class.path=%s" %jarpath,"-Djava.ext.dirs=%s" %dependency)
# 引入java程序中的类.路径应该是项目中的package包路径.类名
javaClass = jpype.JClass('apibankpay.FoPay')
# 创建一个对象
javaInstance  = javaClass ()
# 这一步就是具体执行类中的函数了
result = javaInstance .DoPay(1,"6216261000000000018","交通银行","交通银行","南京","测试","全渠道","20","10012738625")
print ('交易号:'+str(result))
jpype.shutdownJVM()

 

posted @ 2020-07-30 14:25  北极星0202  阅读(1538)  评论(0编辑  收藏  举报