Re: [R] Using Java methods in R

From: hill0093 <hill0093_at_umn.edu>
Date: Tue, 26 Apr 2011 13:01:00 -0700 (PDT)

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
> library(rJava)
> .jinit()
[1] 0
> .jaddClassPath("C:/ad/j")
> print(.jclassPath())
[1] "C:\\Users\\ENVY17\\Documents\\R\\win-library\\2.12\\rJava\\java" [2] "C:\\ad\\j"
> qsLin <- .jnew("CalqsLin")
> calStg <- "201104242359599999"
> print(calStg)
[1] "201104242359599999"
> dblTim <-
> .jcall(qsLin,returnSig="D","linTimOfCalqsStgIsLev",calStg,as.integer(-4))
> print(dblTim,digits=20)

[1] 634709087999999
> calStg <-
> .jcall(qsLin,returnSig="S","calqsStgOfLinTimIsLev",dblTim,as.integer(-4))
> print(calStg)
[1] "201104242359599999"
> conn1Arr <- .jfield(qsLin,sig="[D","con1Arr")
> print(conn1Arr)

[1] 10001 10002 10003 10004 10005 10006
> conn0dbl <- .jfield(qsLin,sig="D","con0dbl")
Error in .jfield(qsLin, sig = "D", "con0dbl") :   RgetField: field con0dbl not found
> arj34Ret <- .jcall(qsLin,returnSig="[[D","arReturnTEST")
> print(arj34Ret[2][3],digits=15)

[[1]]
NULL
> print(arj34Ret,digits=15)

[[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"

> ar34Ret <- .jevalArray(arj34Ret)

Error in .jevalArray(arj34Ret) :
  object is not a Java object reference (jobjRef/jarrayRef).
> print(ar34Ret[2][3],digits=15)

Error in print(ar34Ret[2][3], digits = 15) : object 'ar34Ret' not found
> print(ar34Ret,digits=20)
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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 26 Apr 2011 - 20:03:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Apr 2011 - 11:00:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive