[英]JPype1=0.7.0: TypeError: Unable to convert str ro java type class java.lang.String
When using JPype1 to convert python str to java.lang.String, i got an error on some windows machines while other windows machines not.当使用 JPype1 将 python str 转换为 java.lang.String 时,我在某些 Windows 机器上出现错误,而其他 Windows 机器则没有。
File "lib\\site-packages\\jpype_jobject.py", line 86, in
__new__
文件“lib\\site-packages\\jpype_jobject.py”,第 86 行,在
__new__
TypeError: Unable to convert str to java type class java.lang.String类型错误:无法将 str 转换为 java 类型类 java.lang.String
I pack up the codes into "exe" using PyInstaller 3.5, then run the exe on several windows machines with same JDK, but get different results.我使用 PyInstaller 3.5 将代码打包到“exe”中,然后在具有相同 JDK 的几台 Windows 机器上运行该 exe,但得到不同的结果。
Compile Environment: windows, python 3.6.5 , JPype1 0.7.0, PyInstaller 3.5,编译环境:windows、python 3.6.5、JPype1 0.7.0、PyInstaller 3.5、
Running Environment: windows, JDK 1.8运行环境:windows,JDK 1.8
import jpype
from jpype import JClass
jpype.startJVM(jpype.getDefaultJVMPath())
mystr = "i'm a string"
jstr = jpype.JObject(mystr, JClass("java.lang.String"))
I tried to read the source code " https://github.com/jpype-project/jpype.git " but didn't get any.我试图阅读源代码“ https://github.com/jpype-project/jpype.git ”,但没有得到任何。
Can anyone lead me in the right direction here?任何人都可以在这里引导我朝着正确的方向前进吗?
Finally i found another error log said that JVM was not started successfully.最后我发现另一个错误日志说JVM没有成功启动。 Because there're two versions of jdk on the machine.
因为机器上有两个版本的jdk。 Although "java -version" shows 1.8, but %JAVA_HOME% is still 1.7.
虽然“java -version”显示为 1.8,但 %JAVA_HOME% 仍然是 1.7。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.