python javar send

# -*- coding: utf-8 -*-
import jpype
import os.path
jarpath = os.path.join(os.path.abspath('.'), 'axja')
print("=====>jarpath: " , jarpath)
# jpype=startJVM("D:/devsoft/ultimate/env/jdk/jdk7/Java17017/jre7/bin/server/jvm.dll", "-ea", "-Djava.class.path=%s" % ('D:/pyspace/pyChapter1/test/axja/TesCrypt.jar'))
# startJVM("D:/devsoft/ultimate/env/jdk/jdk7/Java17017/jre7/bin/server/jvm.dll", "-ea", "-Djava.class.path=%s" % (jarpath + 'TesCrypt.jar'))
# startJVM("D:/devsoft/ultimate/env/jdk/jdk7/Java17017/jre7/bin/server/jvm.dll", "-ea")
# startJVM(getDefaultJVMPath(),"-ea", "-Djava.class.path=%s" % (jarpath + 'TesCrypt.jar'))
# startJVM(getDefaultJVMPath(),"-ea", "-Djava.class.path=%s" % (jarpath + 'TesCrypt.jar'))
# JDClass = JClass("jpype.com.azx.crypt.JpypeDemo")
# jvmPath = jpype.getDefaultJVMPath() # 默认的JVM路径
# jvmPath ="D:/envs/jdk/jdk32/jdk7/jdk1.7.0_79/jre/bin/client/jvm.dll" # 默认的JVM路径
jvmPath ="D:/devsoft/ultimate/env/jdk/jdk7/Java17017/jre7/bin/server/jvm.dll" # 默认的JVM路径

print(jvmPath)
# jpype.startJVM(jvmPath,"-ea","-Djava.class.path=%s" % (jarpath + 'TesCrypt.jar'))
# startJVM("C:/Java/jdk1.6.0_10/jre/bin/client/jvm.dll","-ea", "-Djava.class.path=%s" % (jarpath + 'jpypedemo.jar'))



ext_classpath = r'D:pyspacepyChapter1 estaxjaTesCrypt.jar'
#jarpath = os.path.join(os.path.abspath('.'), 'F:/sample_Py/') #os not found
jvmArg = '-Djava.class.path=%s'%ext_classpath
print("=====>jvmArg: " , jvmArg)
jpype.startJVM(jvmPath,'-ea',jvmArg)

# JDClass = JClass("jpype.com.azx.crypt.JpypeDemo")
JDClass = jpype.JClass("com.azx.crypt.JpypeDemo")
jd = JDClass()
jd.sayHello("wxxxxxxaw")
#jd = JPackage("jpype").JpypeDemo() #两种创建jd的方法

jpype.java.lang.System.out.println("hello world!")

# jd = JPackage("jpype.com.azx.crypt.").JpypeDemo() #两种创建jd的方法
# jd = JDClass()
# jd.sayHello("hello world")
jpype.shutdownJVM()
# _*_ coding:utf-8 _*_
import jpype

jvmPath = jpype.getDefaultJVMPath() # 默认的JVM路径

print(jvmPath)
jpype.startJVM(jvmPath)
jpype.java.lang.System.out.println("hello world!")
jpype.java.lang.System.out.println("I hate you!")

jpype.shutdownJVM()
昨日已逝正在输入···
赞赏支持!!!
分享到: 更多
原文地址:https://www.cnblogs.com/rhxuza1993/p/9239343.html