如何解决异常:jpype._jexception.ExceptionPyRaisable:java.lang.Exception:未找到类示例

时间:2015-07-21 09:26:15

标签: java python

Python:2.7 - 32位, Java:jdk7 - 32位, JVM路径:C:\ Program Files(x86)\ Java \ jre7 \ bin \ client \ jvm.dll

Hello.py文件

import jpype
jpype.startJVM(jpype.getDefaultJVMPath())

jpype.java.lang.System.out.println("hello world")

Ex = jpype.JClass("Example")
Exobj = Ex()
print Exobj.addImage()
jpype.shutdownJVM()

同一个包中的Example.java文件

public class Example {
    public String addImage() {
        System.out.println("In java file");
    }
}

执行Hello.py时 - python Hello.py:输出如下

C:\Test>python Hello.py
hello world
Traceback (most recent call last):
  File "C:\Test\hello.py", line 6, in <module>
    Ex = jpype.JClass("Example")
  File "C:\Python27\lib\site-packages\jpype\_jclass.py", line 54, in JClass
    raise _RUNTIMEEXCEPTION.PYEXC("Class %s not found" % name)
jpype._jexception.ExceptionPyRaisable: java.lang.Exception: Class Example not found

0 个答案:

没有答案