0

I want to use .jcall from the rJava package to call a custom java class method.

According to the following example from the rJava-documentation

.jcall("java/lang/System","S","getProperty","os.name")

I tried

.jcall("jrae/src/main/RAEBuilder.java","V","main")

Where "jrae/src/main/RAEBuilder.java" is the path I copied from the eclipse properties of the java class file, "V" represents a void return type and "main" is the method I want to call from the RAEBuilder.java class.

However, the .jcall method returns with

RcallMethod: cannot determine object class

What could be wrong? (please be patient with me, I am a java-novice)

Oblomov
  • 8,953
  • 22
  • 60
  • 106
  • You have to call a java class name, not the source file. Compile `rae/src/main/RAEBuilder.java`, make sure the resulting class is recognized in your R session and then call it – David Gohel Jan 29 '15 at 11:51
  • Thanks for your answer. But which string do I have to use to reference the compiled java class and how do I make sure that it is recognized in the R session? – Oblomov Jan 29 '15 at 12:35
  • I found the problem: I forgot to import the path of the class three through .jaddClassPath before I used .jcall. – Oblomov Jan 30 '15 at 17:11

1 Answers1

0

I found the problem:

I forgot to import the path of the class tree through

.jaddClassPath(path)

before I tried to call the class through .jcall.

Oblomov
  • 8,953
  • 22
  • 60
  • 106