Skip to content
Prev 258051 / 398502 Next

Using Java methods in R

Thanks Icn for pointing that out, but I don't understand it.
My use of .jcall to return a type double scalar or String worked.
My use of .jfield to get a one dimensional static array worked.
My use of .jfield to get a static scalar constant did not work.
My use of .jfield to get a two dimensional static constant array did not
work.
I don't understand the remainder of my rjava trial.

The C:/ad/j/CalqsLin java code is:
  public final static double con0dbl=10001; 
  public final static double[]con1Arr=new double[] {
10001,10002,10003,10004,10005,10006 }; 
  public final static double[][]con2Arr=new double[][] { {
10001,10002,10003,10004 },{ 20001,20002,20003,20004 },{
30001,30002,30003,30004 } }; 
  public final static double[][] arReturnTEST() { 
    double[][]retArr=new double[3][4]; for(int i=0;i<3;i++)for(int
j=0;j<4;j++)retArr[i][j]=i*1000+j; return(retArr); 
  } 
I have the RGui with R Console on the screen; here is the trial:
On the top pullDowns: Packages > Install Packages > USA(IA)> rJava
[1] 0
[1] "C:\\Users\\ENVY17\\Documents\\R\\win-library\\2.12\\rJava\\java"
[2] "C:\\ad\\j"
[1] "201104242359599999"
[1] 634709087999999
[1] "201104242359599999"
[1] 10001 10002 10003 10004 10005 10006
Error in .jfield(qsLin, sig = "D", "con0dbl") : 
  RgetField: field con0dbl not found
[[1]]
NULL
[[1]]
[1] "Java-Array-Object[D:[D at 1d58aae"
[[2]]
[1] "Java-Array-Object[D:[D at 83cc67"
[[3]]
[1] "Java-Array-Object[D:[D at e09713"
Error in .jevalArray(arj34Ret) : 
  object is not a Java object reference (jobjRef/jarrayRef).
Error in print(ar34Ret[2][3], digits = 15) : object 'ar34Ret' not found
Error in print(ar34Ret, digits = 20) : object 'ar34Ret' not found
--
View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3476371.html
Sent from the R help mailing list archive at Nabble.com.