-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand at nhh.no]
Sent: Tuesday, April 06, 2004 5:01 AM
To: STABLER Benjamin
Cc: r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] RE: Using SJava?
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:
Frank and Roger,
Sorry about the path reference - I just added the example on
email and forgot about the R escape character. Attached is
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
jar file to a different directory so it did not find the
using JAVA_HOME = C:\j2sdk1.4.2\jre
.JavaInit(config=javaConfig(classPath="F:/_ben/sig.jar"))
.Java("sig","print","Ben Stabler")
[1] "Ben Stabler" "Oregon Department of
Transportation"
[3] "Mill Creek Office Building" "555 13th Street
[5] "Salem, OR 97301-4178"
The print method of the sig class is static so I'm not
using static methods and I did not need to create a
shouldn't need a constructor/object for a static method
of static methods). Unfortunately my IS department blocked
sent. Could you send me the code as text or maybe just copy
-----Original Message-----
From: Frank Hardisty [mailto:HardistF at gwm.sc.edu]
Sent: Monday, April 05, 2004 1:07 PM
To: Roger.Bivand at nhh.no
Cc: STABLER Benjamin
Subject: Re: [R-sig-Geo] RE: Using SJava?
Roger and Benjamin,
Benjamin, your advice is good and the test class does work.
difficulty is that we were calling a static method of the
does NOT work for some reason. However, the class can be
and used from within R. Here's my session with my mistakes
[Previously saved workspace restored]
using JAVA_HOME = C:\programs\j2sdk_nb\j2sdk1.4.2
.JavaInit(config=javaConfig(classPath="C:/temp/javatest/test.jar"))
testClass <- .JavaConstructor("TestJava")
.Java(testClass,"getMessage")
Benjamin, do you also find that static methods don't work in SJava?
It's hard to understand, because calls to static methods in the Java
runtime libraries work just fine, for example,
[1] 0.07714792
regards,
-Frank
Roger Bivand <Roger.Bivand at nhh.no> 04/05/04 03:36PM >>>
On Mon, 5 Apr 2004 Benjamin.STABLER at odot.state.or.us wrote:
Hopefully, I'm not too late on this one....when you initialize the
need to set the class path as follows:
.JavaInit(config=javaConfig(classPath="StringDirectoryPathReference"))
or
.JavaInit(config=javaConfig(classPath=c("String1", "String2")))
for example:
.JavaInit(config=javaConfig(classPath="C:\javastuff"))
where javastuff contains my class files. You need to
name if you are trying to include class files within jars. I have
with some classes that I wrote.
Yes, and Sys.putenv("CLASSPATH"="String1") can be used too,
you put in .Java() to get into your own jars? Are there
in
the path to the jars? (backslash twice? forwardslash?)
some jars and some instructions for use on a website? Frank Hardisty
sent
me an example off-list that works from the command line but which I
can't
find from within R/SJava (Windows XP, the SJava examples that I've
tried
work for me).
The idea would be to see if GeoTools2 can be reached from within R,
because it could provide (another) way to import/export
I too am excited about linking Java and R, as there is so
in the Java community.
Benjamin Stabler
Transportation Planning Analysis Unit
Oregon Department of Transportation
555 13th Street NE, Suite 2
Salem, OR 97301 Ph: 503-986-4104
Message: 5
Date: Fri, 2 Apr 2004 20:56:50 +0200 (CEST)
From: Roger Bivand <Roger.Bivand at nhh.no>
Subject: [R-sig-Geo] Using SJava?
To: r-sig-geo at stat.math.ethz.ch
Cc: Frank Hardisty <HardistF at gwm.sc.edu>
Message-ID:
<Pine.LNX.4.44.0404022042580.28093-100000 at reclus.nhh.no>
Content-Type: TEXT/PLAIN; charset=US-ASCII
Is anyone on this list using SJava or any R/Java connection?
Not only is
the JTS Topology Suite that Tim just mentioned interesting,
but so is the
upcoming GeoTools2 at http://www.geotools.org/. Both are
likely to be used
quite a lot, and thus probably well-maintained.
At the recent Association of American Geographers meeting,
Frank Hardisty
asked me about this, and while I was able to install SJava (from
http://www.stats.ox.ac.uk/pub/RWin) on a Win XP laptop, we
were not able
to see how to get Java within R to see GeoTools in its
classpath. Both of
these Java resources are potentially useful, and R opinions
two or three
years ago, that Java is slow, may need revision given increased
capacity. I feel we could benefit from mobilizing Java insight
(but I feel
personally Java-challenged!).
I believe that Duncan Temple-Lang was playing
discovery - this could be very relevant in terms of matching
R-internal
object representations with those in existing software that we
could - if
SJava worked - link to. I also think that we could ask him for
advice if
we discussed it first here. What do others think?
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian
School of
Economics and Business Administration, Breiviksveien 40, N-5045
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no