简体   繁体   English

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

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.

相关问题 无法将“java.lang.String”类型的值转换为所需类型 - Cannot convert value of type 'java.lang.String' to required type 类型不匹配:无法从java.lang.String转换为String - Type mismatch: cannot convert from java.lang.String to String 类型不匹配:无法从 java.lang.String 转换为 String - Type missmatch: cannot convert from java.lang.String to String 无法将类型为java.lang.String的J转换为xxx类 - Cannot convert J of type class java.lang.String to class xxx 无法转换类型[java.lang.String]的属性值 - Failed to convert property value of type [java.lang.String] DatabaseException:无法将java.Lang.String对象转换为类型 - DatabaseException: can't convert object of java.Lang.String to type 错误:无法将 java.lang.String 类型的值转换为 int - Error: Failed to convert a value of type java.lang.String to int 如何使用JAXB从schema(.xsd)生成类期间将复杂类型转换为java.lang.string - How to Convert Complex Type in to java.lang.string during class generation from schema(.xsd) using JAXB 无法将[text / plain,UTF-8]表示转换为类java.lang.String的对象 - Unable to convert a [text/plain,UTF-8] representation into an object of class java.lang.String JAXB,Marshal的问题-无法封送类型“ java.lang.String” - Problems with JAXB, Marshal, - unable to marshal type “java.lang.String”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM