1 ''' 2 Created on 2016年6月1日 3 4 @author: cero 5 ''' 6 import jpype 7 8 jvmPath = jpype.getDefaultJVMPath() 9 ext_classpath = '/home/cero/temp/chinapnr.jar' 10 jvmArg = '-Djava.class.path=' + ext_classpath 11 if not jpype.isJVMStarted(): 12 jpype.startJVM(jvmPath, jvmArg) 13 system = jpype.java.lang.System 14 system.out.println('hello world!') 15 system.out.println(system.getProperty("user.dir")) 16 SecureLink = jpype.JClass('chinapnr.SecureLink') 17 sl = SecureLink() 18 ret = sl.EncMsg("/home/cero/temp/PgPubk.key", 'aaaa') 19 EncMsg = sl.getEncMsg() 20 print(ret) 21 print(EncMsg) 22 jpype.shutdownJVM()
开始一直无法导入第三方包,提示class not found;
使用jar包的完整路径后成功导入。