JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String

JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String

当使用 JPype1 将 python str 转换为 java.lang.String 时,我在某些 windows 机器上出现错误,而其他 windows 机器则没有。

File "lib\site-packages\jpype_jobject.py", line 86, in __new__
TypeError: Unable to convert str to java type class java.lang.String

我使用 PyInstaller 3.5 将代码打包到 "exe" 中,然后 运行 在几台 windows 机器上使用相同 JDK 的 exe,但得到不同的结果。

编译环境:windows,python3.6.5,JPype1 0.7.0,PyInstaller 3.5,
运行环境:windows、JDK1.8

import jpype
from jpype import JClass

jpype.startJVM(jpype.getDefaultJVMPath())
mystr = "i'm a string"
jstr = jpype.JObject(mystr, JClass("java.lang.String"))

我试图阅读源代码“https://github.com/jpype-project/jpype.git”,但没有得到。

谁能给我指引正确的方向?

最后我发现另一个错误日志说JVM没有启动成功。因为机器上有两个版本的 jdk。虽然"java -version"显示的是1.8,但是%JAVA_HOME%还是1.7。