I have written some java code in an adapter in worklight project. when i m trying to call the java method, i am getting an error saying
"responseID":"6","errors": {Ecma Error: TypeError: Cannot call property downloadFile in object JavaPackage java.classes.FileIOPlugin]. It is not a function, it is \"object\".}
I have followed the procedure exactly stated in the following link. Using Java in Adapters
this is my project structure. Is there something wrong with this structure or should i add anything more to this?
This is how i am trying to call the java non-static method in adapter-impl.js
function downloadFile() {
var fileInstance = new com.worklight.JavaCode.FileIOPlugin();
return
{ result: fileInstance.downloadFile(); };
}
We have identified another possible solution to this.
Make sure your package starts with com, e.g. rename it to "com.classes".
Check your .project file and make sure it has the right buildCommand tags in it.
Read more at: ECMA TypeError calling Java class from Worklight adapter
Try adding the parenthesis when you instantiate your object: