lynnetest

一、环境准备

1.Python 3.6 64位+jre 64位+win64位(jre和Python位数一致)

2.安装jpype,安装的时候输入 pip install jpype1

2.1安装提示error: Microsoft Visual C++ 14.0 is required...

解决办法:https://blog.csdn.net/tayhh/article/details/78601889

二、两种调用jar包的方法

1.通过命令行

import subprocess
import chardet
import sys

class AES(object):
def __init__(self, data):
self.data = data

def encrypt(self):
command = "java -jar testImportJar.jar"
arg0 = self.data
cmd = [command,arg0]
new_cmd = " ".join(cmd)
stdout,stderr = subprocess.Popen(new_cmd,stdout=subprocess.PIPE,stderr=subprocess.PIPE).communicate()
encoding = chardet.detect(stdout)["encoding"]
result = stdout.decode(encoding)
return result

if __name__ == \'__main__\':
data = sys.argv[0]
AES = AES("222")
print(AES.encrypt())
2.通过Jpype
import jpype
jvmPath = jpype.getDefaultJVMPath()
jvmPath = r\'C:\Program Files\Java\jre1.8.0_65\bin\server\jvm.dll\'#python 2.X用ur,Python 3.X用r
jpype.startJVM(jvmPath)
PWD = "&*($HJDGH4867%&T345386754OHYOH*^(ughiuR5fu&f&$KHAOS$&^%"
jpype.java.lang.System.out.println("hello")
jpype.shutdownJVM()


分类:

技术点:

相关文章:

  • 2021-03-28
  • 2021-04-02
  • 2021-06-19
  • 2021-12-21
  • 2021-08-06
  • 2021-11-26
猜你喜欢
  • 2021-10-22
  • 2021-10-07
  • 2022-01-15
  • 2021-09-14
  • 2021-06-09
  • 2021-09-29
  • 2021-10-09
相关资源
相似解决方案