I guess your failure of getting two dimensional array may be related to this :
http://www.rforge.net/rJava/news.html
"0.9-0   (under development)
    o   fixes issues introduced by several new features in the late
        0.8 series. Most imporantly .jarray() and .jevalArray() behave
        as intended (and as implemented in previous versions). The
        same applies to .jcall() behavior with respect to arrays and
        its evalArray arument. The defaults for some new arguments
        have been changed to reflect the original behavior.
   o   .jevalArray() has an additional argument `simplify' which allows
        multi-dimensional arrays to be converted to native R
        types. Use with care - it may convert more recursive types in
        the future so it should be used preferrably where you have
        control over the types converted.
   o   fixed a bug in .jevalArray that was not simplifying string
        vectors correctly when the array type was not specified
        (.jclass returns dot notation whereas signatures use JNI
        notation so a conversion was necessary)"

So for multi-dimensional array, the.jevalArrayfunction has not been fully 
implemented in rJava release.

As for the static double field con0dbl, it's pretty weild since it works well 
when I tested your code.

One more notice, ar34Ret[2][3] should be "ar34Ret[2,3]" in R.

At 2011-04-27 04:01:00£¬hill0093 <hill0...@umn.edu> wrote:

>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@1d58aae"
>[[2]]
>[1] "Java-Array-Object[D:[D@83cc67"
>[[3]]
>[1] "Java-Array-Object[D:[D@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@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.

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to