0

My problem is similar to this one : Even with adding the semicolon didn't work for me this is my method when i call .jmethod to display it for me :

[10] "public java.util.Set utils.Rinterface.getPhones()"

when I call the method, Like this

rJava::.jcall(rinterface,"Ljava.util.Set;","getPhones")

I got this error :

rJava::.jcall(rinterface, "Ljava.util.Set;", "getPhones") : method getPhones with signature ()Ljava.util.Set; not found it gives that error, still don't know whats wrong ?!

1 Answers1

1

You can try with this sample tree structure:

.
└── utils
    └── Rinterface.java

and with super simple class

package utils;

import java.util.Set;

public class Rinterface {
    public java.util.Set getPhones() {
        return new java.util.HashSet();
    }
}

make sure to compile it with the same Java version you are using with rJava.

Set up Java env

library(rJava)
.jinit()
# note that you have to point to place where utils directory is
.jaddClassPath(dir("place_where_your_package_is",full.names=TRUE))
obj <- .jnew("utils.Rinterface")
# call method
result=.jcall(obj, returnSig="Ljava/util/Set;", method="getPhones")

you can always get the signature of method with

Compiled from "Rinterface.java"
public class utils.Rinterface {
  public utils.Rinterface();
    descriptor: ()V

  public java.util.Set getPhones();
    descriptor: ()Ljava/util/Set;
}

In my case, it works as expected.

Update:

in your case, you use:

Ljava.util.Set;

replace it with

Ljava/util/Set;

Update:

Updated to reflect proper package layout

Oo.oO
  • 12,464
  • 3
  • 23
  • 45