python调用jar包

发布时间:2019-09-01 10:50:54编辑:auto阅读(2042)

    import os
    from jpype import *

    jarpath = os.path.join(os.path.abspath('.'), 'path/xx.jar')
    startJVM(getDefaultJVMPath(), "-Djava.class.path=%s" % jarpath)
    FormatScript = JClass('com.TestMain')
    t = FormatScript()url = ["http://www.test.com/8556.htm"]
    t.test(url)content = t.content
    java.lang.System.out.println(content)
    shutdownJVM()

关键字