Jpype 将参数传递给 Java
Jpype passing arguments to Java
我有一个 java 程序员,下面一行
service.loadPropertiesForItems(Inbox, new PropertySet(ItemSchema.Subject, ItemSchema.Body));
程序从外部 jar 调用 classes 和方法。
我想在 python 中编写等效代码,它像我的 java 程序一样调用外部 jar。
我使用 Jpype 实现了代码,但在下一行
上失败了
service.loadPropertiesForItems(inbox, ewsPkg.PropertySet(ewsPkg.ItemSchema.Subject, ewsPkg.ItemSchema.Body))
这里的 PropertySet、ItemSchema 是我从外部 jar 中使用的 classes。
ItemSchema.Subject 和 ewsPkg.ItemSchema.Body 是 class 类型
运行代码我在上面提到的行中遇到以下错误 -
service.loadPropertiesForItems(inbox, ewsPkg.PropertySet(ewsPkg.ItemSchema.Subject, ewsPkg.ItemSchema.Body))
File "C:\Python27\lib\site-packages\jpype\_jclass.py", line 79, in _javaInit
self.__javaobject__ = self.__class__.__javaclass__.newClassInstance(*args)
RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121
谢谢
正如马丁所建议的那样https://github.com/originell/jpype/issues/117
以下代码运行良好
ItemSchema = ewsPkg.ItemSchema
PropertyDefinition = ewsPkg.PropertyDefinition
Subject = ItemSchema.Subject
Body = ItemSchema.Body
args = JArray(PropertyDefinition)([ItemSchema.Subject, Body])
PropertySet = ewsPkg.PropertySet(args)
我有一个 java 程序员,下面一行
service.loadPropertiesForItems(Inbox, new PropertySet(ItemSchema.Subject, ItemSchema.Body));
程序从外部 jar 调用 classes 和方法。
我想在 python 中编写等效代码,它像我的 java 程序一样调用外部 jar。 我使用 Jpype 实现了代码,但在下一行
上失败了service.loadPropertiesForItems(inbox, ewsPkg.PropertySet(ewsPkg.ItemSchema.Subject, ewsPkg.ItemSchema.Body))
这里的 PropertySet、ItemSchema 是我从外部 jar 中使用的 classes。 ItemSchema.Subject 和 ewsPkg.ItemSchema.Body 是 class 类型
运行代码我在上面提到的行中遇到以下错误 -
service.loadPropertiesForItems(inbox, ewsPkg.PropertySet(ewsPkg.ItemSchema.Subject, ewsPkg.ItemSchema.Body))
File "C:\Python27\lib\site-packages\jpype\_jclass.py", line 79, in _javaInit
self.__javaobject__ = self.__class__.__javaclass__.newClassInstance(*args)
RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121
谢谢
正如马丁所建议的那样https://github.com/originell/jpype/issues/117
以下代码运行良好
ItemSchema = ewsPkg.ItemSchema
PropertyDefinition = ewsPkg.PropertyDefinition
Subject = ItemSchema.Subject
Body = ItemSchema.Body
args = JArray(PropertyDefinition)([ItemSchema.Subject, Body])
PropertySet = ewsPkg.PropertySet(args)