0

尝试使用 jpype 从 python 调用 java 类时获取类未找到异常。以下是版本和路径详细信息:

JPype版本:JPype1-py3

蟒蛇:3.6

爪哇:1.8.0_171

Java 文件路径:/home/neha/Downloads/fontAttributes/PDFFontExtractor.java

Python 文件路径:/home/neha/Downloads/call_java.py

下面是 Python 代码:call_java.py

import jpype
from jpype import *
cpath="-Djava.class.path=%s" % ("/home/neha/Downloads")
startJVM(getDefaultJVMPath(), "-ea",cpath)
Test = JClass('fontAttributes.PDFFontExtractor')
Test.getFontAttributes()
java.lang.System.out.println(str)
shutdownJVM()

输出:

/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so
Traceback (most recent call last):
File "call_java.py", line 14, in <module>
Test = JClass('fontAttributes.PDFFontExtractor')
File "/usr/local/lib/python3.6/dist-packages/jpype/_jclass.py", line 55, in JClass
raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.ExceptionPyRaisable: java.lang.Exception: Class fontAttributes.PDFFontExtractor not found
4

0 回答 0