[R] R and Java

Thomas Lumley tlumley at u.washington.edu
Tue Oct 2 18:51:54 CEST 2001

On Tue, 2 Oct 2001, Andrew Schuh wrote:

> I finally got it running (sorta) on my RH7.1.  I would make sure you
> have the latest package from Omegahat first.  Then, I believe the  most
> likely culprit is the LD_LIBRARY_PATH env variable.  Mine includes the
> following (my bash profile).
> LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/R/library/SJava/libs:/opt/IBMJava2-13/jre/bin:
> /opt/IBMJava2-13/jre/bin/classic:/usr/lib:/usr/local/lib/R/bin:/usr/local/lib/R/library/SJava/org/omegahat/Jars/ROmegahatExamples.jar:.;
> You can replace the java directories with the jdk you are using.  Also
> make sure that error messages aren't pointing you to a '.so' (in the
> libs directory of SJava) that you don't have.  I had to rename one of
> them in an earlier version of the SJava package.
> Even with this, I am only able to run an example after I run java at
> least once.  I would open the BASH shell and run any java class and then
> open R and be able to run the examples (
> library(SJava);.JavaInit();source(....example.r);example.r();  )  .
> This makes it a little difficult to use the package (or at the least,
> inelegant) by running R in batch.  I have had a lot of difficulty
> creating any original code with this package.  My goal was to create
> some original code to allow me to run a java app that called R.  Not
> much luck.  I put a message out some time ago but I haven't had much
> luck getting responses.  If anyone out there has had any luck using this
> package with Redhat and IBM JDK please let me know.  Hope this helps.

It works (at least works better) when the .JavaInit() call specifies all
the classpaths you are going to use

The following snippet is from a demonstration that worked (even in front
of other people) under Windows. An earlier version with Unix path names
also worked under Debian, but I haven't tried that recently.

##set up paths
orcaHomeDir<-"C:/Program Files/R/rw1030/library/orcaR/"
orcaHomeOrcaJar <- paste(orcaHomeDir,"exec/orca.jar",sep="")
orcaHomeVisADJar <- paste(orcaHomeDir,"exec/visad.jar",sep="")
orcaHomeGrappaJar <- paste(orcaHomeDir,"exec/grappalite.jar",sep="")
orcaHomeJaxpJar <- paste(orcaHomeDir,"exec/jaxp.jar",sep="")
orcaHomeParserJar <- paste(orcaHomeDir,"exec/parser.jar",sep="")
orcaClasses <- c(orcaHomeOrcaJar,orcaHomeVisADJar,
## Initialize JVM
## Verify JVM
.Java("System", "getProperty", "java.class.path")

## Same example
TaoDataFile     <- paste(orcaHomeDir,"data/orca.tao.time",sep="")
TaoDataGroupVar  <- "Group"
TaoDataTimeVar <- "Time"

od.1 <- .Java("org.orca.data.parsers.OrcaDataSource",


Thomas Lumley			Asst. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list