[R] Using Java methods in R

Mike Marchywka marchywka at hotmail.com
Sat Apr 23 21:12:30 CEST 2011
















----------------------------------------
> Date: Sat, 23 Apr 2011 05:32:59 -0700
> From: hill0093 at umn.edu
> To: r-help at r-project.org
> Subject: Re: [R] Using Java methods in R
>
> No answer to my post,
> so let's try a simpler question. Am I doing this correctly?
> I have the RGui with R Console on the screen.
> On rhe top pullDowns, Packages > Install Packages > USA(IA)> rJava
> > library(rJava)
> > .jinit()
> > qsLin <- .jnew("C:/ad/j/CalqsLin")
> Error in .jnew("C:/ad/j/CalqsLin") :
> java.lang.NoClassDefFoundError: C:/ad/j/CalqsLin

i haven't used rjava yet, I think I installed it on linux
for testing but no real usage, but this message
appears to come from jvm probably because you
specified an aboslute path. You can try this from
command line,




$ ls ../geo/dayte*
../geo/dayte.class

mmarchywka at phlulap01 /cygdrive/c/d/phluant/duphus
$ java ../geo/dayte
Exception in thread "main" java.lang.NoClassDefFoundError: ///geo/dayte
Caused by: java.lang.ClassNotFoundException: ...geo.dayte
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: ../geo/dayte.  Program will exit.


you want to search for the classpath and set that up then
refernce the class name not the path ( the class loader will follow
the path looking for it ). 
Not sure how you do that in rjava under 'dohs but
if you search for that term is should be apparent.
And of course 'dohs and pdf aren't always friendly
for automated work so get something like cygwin and
reduce pdf's to text etc.






>
> So I got this error which means I don't understand very much.
> I go to C:/ad/j and get
> C:\ad\j>dir CalqsLin.class
> Volume in drive C has no label.
> Volume Serial Number is 9A35-67A2
> Directory of C:\ad\j
> 04/23/2011 07:11 AM 14,651 CalqsLin.class
> 1 File(s) 14,651 bytes
> 0 Dir(s) 104,257,716,224 bytes free
>
> Just to show my intentions,
> I had next wanted to call this java function method:
> linTimOfCalqsStgIsLev("201104052359599999",-4) using:
> > dblTim <-
> > .jcall(qsLin,"D","linTimOfCalqsStgIsLev","201104052359599999","-4")
> but that will probably also be wrong?
> Obviously I don't understand.
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Using-Java-methods-in-R-tp3469299p3469848.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.
 		 	   		  


More information about the R-help mailing list