Question

I want to run java class in my python code and I use the tool JPype. I have a java method with a boolean argument. It works in java code but when I call it in python, I get the error message:

RuntimeError: No matching overloads found. at src/native/common/jp_method.cpp:121

I even use the jpype wrapper JBoolean, but it still fails. For example, the code in java is:

item.myMethod(true);

and I have tried to convert it in python as:

item.myMethod(1)
item.myMethod(True)
item.myMethod(jpype.JBoolean(True))
item.myMethod(jpype.JBoolean(1))

but all of above get the same error message. Could anyone help me to convert the boolean argument from python to java?? thank you!!

No correct solution

OTHER TIPS

Is the argument of your Java method defined as a boolean or a java.lang.Boolean?

If it is boolean, then all the possibilities you have tried should work (if not there might be something wrong with the way you import the Class in your Python code). However, if it's a java.lang.Boolean, then you have to call your method as such:

item.myMethod(jpype.java.lang.Boolean(True))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top