如何解决在Python 3.7中调用Java程序的问题?

时间:2019-12-15 18:11:07

标签: java python

我目前在python3.7中具有此功能

def sign(self, xml_document, file_pk12, password):
    xml_str = xml_document.encode('utf-8')
    JAR_PATH = 'firma/firmaXadesBes.jar'
    JAVA_CMD = 'java'
    firma_path = os.path.join(os.path.dirname(__file__), JAR_PATH)
    command = [
        JAVA_CMD,
        '-jar',
        firma_path,
        xml_str,
        base64.b64encode(bytes(file_pk12,"utf-8")),
        base64.b64encode(bytes(password,"utf-8"))
    ]
    try:
        logging.info('Testing command for digital signature')
        subprocess.check_output(command)
    except subprocess.CalledProcessError as e:
        returncode = e.returncode
        output = e.output
        logging.error('Calling JAVA process code: %s' % returncode)
        logging.error('Error: %s' % output)

    p = subprocess.Popen(
        command,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT
    )
    res = p.communicate()
    return res[0]

但是我有这个错误

root:错误:b'VM初始化期间发生错误\ n无法分配元空间:1073741824字节\ n


0 个答案:

没有答案