[R] launching RSJava from external application

Sean sean.xiao.wang at gmail.com
Sat Jun 11 00:15:00 CEST 2005


Hi,all,

I have a problem about launching SJava in R from external application
(Cytoscape).

My R version is 2.1.0 and Sjava version is 0.68. R is installed by issuing

   1.  configure --enable-R-shlib
   2. make
   3. make check
   4. make install

SJava is installed by issuing  "R CMD INSTALL -c SJava_version_.tar.gz". 

The LD_LIBRARY_PATH is set in .bash_profile by
"LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/R/library/SJava/libs:/usr/java/j2sdk1.4.2_08/jre/lib/i386/client:/usr/java/j2sdk1.4.2_08/jre/lib/i386:/usr/java/j2sdk1.4.2_08/jre/../lib/i386:
export LD_LIBRARY_PATH"

After installation, type the following command
    *  library(SJava)
    * .JavaInit()
    * .Java("java.lang.System", "getProperty", "java.class.path")
    * names(.Java("java.lang.System", "getProperties"))

Get the correct output (omitted here) .

Now the question is:

I am using R to interact with Cytoscape ( a visualization tool), which
has a plugin called "Cytotalk" that can let R and Cytoscape talk to
each other. I successfully ran a R script which need SJava and got the
right output in Cytoscape.

But when I tried to run the R script from the cytoscape menu ( the
plugin enabled a menu in which you can choose a R file to execute it
and display the output in Cytoscape ), the terminal give me the
following error:


Accepting clients from localhost
> port <- 8082
> library(SJava)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
        unable to load shared library
'/usr/local/lib/R/library/SJava/libs/SJava.so':
  libRSNativeJava.so: cannot open shared object file: No such file or directory
Error in library(SJava) : .First.lib failed for 'SJava'
Execution halted
RESULT: 1

I googled around and found it was a common error when people trying to
install SJava. But I installed SJava correctly and it seems work fine,
I can not figure out why it comes up with this error.

To give you some background information, I guess Cytoscape and R talk
with each other via various java stuff. The fact that I can interact
with Cytoscape from within R showing that the .jar directory should be
fine.

The first few lines of the R code is like :

library(SJava)
#Warning message:
#The Java machine is no longer initialized automatically. You must
explicitly load it in: f(libname, pkgname)
                                                                                
a=javaConfig(classPath="/usr/local/bio/cytoscape/plugins/cytoTalk.jar")
.JavaInit(config=a)
#.Java("System","getProperty","java.class.path")
#[1] ":/usr/local/bio/cytoscape/plugins/cytoTalk.jar:/usr/local/lib/R/library/SJava/org/omegahat/Jars/Environment.jar:/usr/local/lib/R/library/SJava/org/..:/usr/local/lib/R/library/SJava/org/omegahat/Jars/antlr.jar:/usr/local/lib/R/library/SJava/org/omegahat/Jars/jas.jar:/usr/local/lib/R/library/SJava/org/omegahat/Jars/jhall.jar"
                                                                                
source("CytoTalkClient-v2.R")
cy <- .JNew("CytoTalkClient","http://localhost:8082")

And by the way, my OS is Redhat Linux. I really appreciate it if
someone has an clue of the  problem. Thanks.

Xiao




More information about the R-help mailing list