Skip to content

Using SJava?

2 messages · Benjamin.STABLER at odot.state.or.us, Roger Bivand

#
Frank and Roger,

Sorry about the path reference - I just added the example on the fly in the
email and forgot about the R escape character.  Attached is the simply class
that I used to test the link.  It just takes a string as an input and
returns my email signature with the string substituted for the name.

The R code to run it:

library(SJava)
.JavaInit(config=javaConfig(classPath="F:/_ben/java"))
.Java("sig","print","Ben Stabler")


In terms of the jar file, it seems to work for me.  Note that I moved the
jar file to a different directory so it did not find the class file by
itself as well.
using JAVA_HOME = C:\j2sdk1.4.2\jre
[1] "Ben Stabler"                         "Oregon Department of
Transportation"
[3] "Mill Creek Office Building"          "555 13th Street NE Suite 2"

[5] "Salem, OR 97301-4178"
The print method of the sig class is static so I'm not having any difficulty
using static methods and I did not need to create a constructor first.  You
shouldn't need a constructor/object for a static method (that is the point
of static methods).  Unfortunately my IS department blocked the zip file you
sent.  Could you send me the code as text or maybe just copy into email?
Thanks.  

Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sig.class
Type: application/octet-stream
Size: 476 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20040405/3931ed6a/attachment.class>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sig.java
Type: application/octet-stream
Size: 342 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20040405/3931ed6a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sig.jar
Type: application/octet-stream
Size: 809 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20040405/3931ed6a/attachment-0001.obj>
#
Again, very promising, the simple jars can be accessed - what is the next 
step?

So far we have SJava (the Windows binary downloaded from 
http://www.stats.ox.ac.uk/pub/RWin) talking to itself, and to two simple 
Java examples. There are two issues, the classpath one, and whether or not 
to call .JavaConstructor() to create a copy on the R side of the class. Is 
there a way of asking a jar to reveal the class names it contains - are 
the class structures "discoverable". Could I ask "sig" for its length, for 
example?

I'm keeping this discussion on the list for now, because accessing 
geotools (and other Java resources) is at least worth trying, and to do 
that more hands and eyes are needed.

Roger
On Mon, 5 Apr 2004 Benjamin.STABLER at odot.state.or.us wrote: