[R] R and Java

Duncan Temple Lang duncan at research.bell-labs.com
Wed Oct 3 16:23:44 CEST 2001


Hi Olivier.

  For (what I believe are) technical reasons, if you get an error in R
before initializing the Java virtual machine (JVM), very bad things
happen when you do actually start Java via the .JavaInit() function.
So the thing to try is running R, and immediately loading the SJava
library and initializing the JVM. 
 (R
   > library(SJava)
   > .JavaInit()
)
Then things should be better and we can start dealing with any other problems.

The technical reasons that I believe are causing the problem are what
make the S-Java connection somewhat less stable than other
packages. Specifically they relate to the fact that Java and the
underlying implementation uses threads, while R does not. And all the
libraries that they share in common (libc, libm, ...) are slightly
different and whoever gets to load them first wins and sets the
environment for the other.  When running Java inside R, R wins.  On
Unix, you can run Java and call R from within Java. In that setup,
Java will load the correct libraries for itself and R will be happy
with the result.

As Andrew pointed out, setting the LD_LIBRARY_PATH environment
variable correctly is important. And ensuring that the same JVM is
used at run time as used at compile time is usually vital.  To to do
this, the package supplies two shell scripts (one for the C shell and
another for the Bourne shell) in the scripts/ directory which can be
sourced to set the necessary environment variables.

Hope this helps. I'm keen to hear about other problems.
 D.

Olivier Martin wrote:
> Daer all,
> 
> Before to expose my problem, this the configuartion of my environment.
> I use the version 1.2.1 of R  with a  limux system (redhat)
> 
> I have installed SJava  (from omeghat) package successfully.
> So, i wanted to try an example (calc.R) that is provided in the library.
> 
> This is the message I obtained:
> Error in isJavaInitialized("Java virtual machine has not been
> initialized. Call .JavaInit
> Java virtual machine has not been initialized. Call .JavaInit()
> 
> So, i tried .JavaInit() but i obtained Segmentation fault (core dumped)
> 
> Could somebody  help me ?
> Thanks,
> Olivier
> 
> --
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> Olivier MARTIN
> PhD student                  phone: (33) 04 76 61 53 55
> Projet IS2                               06 08 67 93 42
> INRIA Rhone-Alpes            fax  : (33) 04 76 61 54 77
> 655, Av. de l'Europe
> Montbonnot                   e-mail:olivier.martin at inrialpes.fr
> 38334 Saint Ismier cedex
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 
> 

-- 
_______________________________________________________________

Duncan Temple Lang                duncan at research.bell-labs.com
Bell Labs, Lucent Technologies    office: (908)582-3217
700 Mountain Avenue, Room 2C-259  fax:    (908)582-3340
Murray Hill, NJ  07974-2070       
         http://cm.bell-labs.com/stat/duncan
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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