[R] SJava help

Henrik Bengtsson hb at maths.lth.se
Wed Sep 24 20:42:56 CEST 2003


Hi, I do not have Linux myself but looking at your error message

> > .JavaInit()
> [1] error initializing manager class can't find class 
> java/lang/Hashtable Error in .JavaInit() : Couldn't start 
> Java Virtual Machine: can't find class java/lang/Hashtable
> > 

it looks like you have not set the JAVA_HOME variable correctly. On a
Windows XP machine you will get the error (together with a popup
dialog):

> library(SJava)
using JAVA_HOME = /c/Program Files/Java/j2sdk1.4.0_02
Error in dyn.load(x, as.logical(local), as.logical(now)) :
        unable to load shared library
"c:/PROGRA~1/R/rw1071/library/SJava/libs/S
Java.dll":
  LoadLibrary failure:  The specified module could not be found.
Error in library(SJava) : .First.lib failed
>

See help(.Renviron) how to set the JAVA_HOME environment variable. 

***Note*** on Windows XP (and maybe on other systems too) you have to
set JAVA_HOME differently if you have i) Java Runtime Edition or the ii)
Java SDK. For Java SDK, which you have, you have to set

  JAVA_HOME=C:/Program Files/Java/j2sdk1.4.0_02/jre/

and not to

  JAVA_HOME=C:/Program Files/Java/j2sdk1.4.0_02/

as one would guess. But with Java Runtime Edition you should do

  JAVA_HOME=C:/Program Files/Java/j2re1.4.1_02/

If you use ~/.Renviron it won't mess with your other settings. 

Again, I'm not sure if this applies to Linux, but it's worth a try.

Cheers

Henrik Bengtsson


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Weiming Zhang
> Sent: den 24 september 2003 19:16
> To: R-help at stat.math.ethz.ch
> Subject: [R] SJava help
> 
> 
> Hi,
> 
> I installed SJava 0.66-1 on my linux RH 7.2 machine. I am 
> using R-1.7.1. I set LD_LIBRARY_PATH up then called 
> library(SJava) and it was fine. But when I called 
> .JavaInit(),  I got weird error that states it could not find 
> java/lang/Hashtable. The session is below and shows my java 
> configuration. I am using j2sdk1.4.2_01 from Sun.
> 
> Thank you very much.
> 
> Weiming Zhang
> 
> > .javaConfig
> $classPath
> [1] "/usr/lib/R/library/SJava/org/omegahat/Jars/Environment.jar"
> [2] "/usr/lib/R/library/SJava/org/.."                           
> [3] "/usr/lib/R/library/SJava/org/omegahat/Jars/antlr.jar"      
> [4] "/usr/lib/R/library/SJava/org/omegahat/Jars/jas.jar"        
> [5] "/usr/lib/R/library/SJava/org/omegahat/Jars/jhall.jar"      
> 
> $properties
>                                                                 
> EmbeddedInR 
>                                                                      
> "true" 
>                                                       
> InterfaceManagerClass 
>             
> "org/omegahat/Interfaces/NativeInterface/OmegaInterfaceManager" 
>                                                   
> ForeignReferenceBaseClass 
>                                     
> "org/omegahat/R/Java/RForeignReference" 
>                                                               
> java.compiler 
>                                                                      
> "NONE" 
>                                                                  
> OMEGA_HOME 
>                                     
> "/usr/lib/R/library/SJava/org/omegahat" 
>                                                          
> OmegahatSearchPath 
> ".,${OMEGA_HOME}/Environment/Scripts/Run,${OMEGA_HOME}/Jars/En
> vironment.jar" 
>                                                           
> java.library.path 
>                                             
> "/usr/lib/R/library/SJava/libs" 
> 
> $libraryPath
> [1] "/usr/lib/R/library/SJava/libs"
> 
> $args
> character(0)
> 
> > .JavaInit()
> [1] error initializing manager class can't find class 
> java/lang/Hashtable Error in .JavaInit() : Couldn't start 
> Java Virtual Machine: can't find class java/lang/Hashtable
> > 
> 
> The output from installation is here and 
> I used R INSTALL -c SJavaPackageName:
> 
> * Installing *source* package 'SJava' ...
> creating cache ./config.cache
> checking for java... /opt/lang/java/j2sdk1.4.2_01/bin/java
> Java VM /opt/lang/java/j2sdk1.4.2_01/bin/java
> checking for javah... /opt/lang/java/j2sdk1.4.2_01/bin/javah
> checking for c++... c++
> checking whether the C++ compiler (c++  ) works... yes
> checking whether the C++ compiler (c++  ) is a 
> cross-compiler... no checking whether we are using GNU C++... 
> yes checking whether c++ accepts -g... yes checking for 
> gcc... gcc checking whether the C compiler (gcc  ) works... 
> yes checking whether the C compiler (gcc  ) is a 
> cross-compiler... no checking whether we are using GNU C... 
> yes checking whether gcc accepts -g... yes checking for 
> Rf_initEmbeddedR in -lR... no No R shared library found 
> updating cache ./config.cache creating ./config.status 
> creating Makevars creating src/Makevars creating 
> src/RSJava/Makefile creating Makefile_rules creating 
> inst/scripts/RJava.bsh creating inst/scripts/RJava.csh 
> creating R/zzz.R creating cleanup creating inst/scripts/RJava 
> Copying the cleanup script to the scripts/ directory Building 
> libRSNativeJava.so in /tmp/R.INSTALL.30363/SJava/src/RSJava
> if  test ! -d /usr/lib/R/library/SJava/libs ; then \
>     mkdir /usr/lib/R/library/SJava/libs ; \
> fi
> gcc -g -O2 -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux  -c CtoJava.c
> gcc -g -O2 -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux  -c 
> ErrorHandling.c gcc -g -O2 -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux  -c 
> ManagerInterfaceUtils.c gcc -g -O2 -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux  -c References.c 
> gcc -g -O2 -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux  -c JNIUtils.c
> gcc -shared  -o libRSNativeJava.so CtoJava.o ErrorHandling.o 
> ManagerInterfaceUtils.o References.o JNIUtils.o 
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386/client
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386
> -L/opt/lang/java/j2sdk1.4.2_01/jre/../lib/i386 -ljvm 
> -L/tmp/R.INSTALL.30363/SJava/inst/libs
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386/client
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386
> -L/opt/lang/java/j2sdk1.4.2_01/jre/../lib/i386
> -L/usr/lib/R/library/SJava/libs 
> if test -n "CtoJava.h ErrorHandling.h JNIUtils.h 
> ManagerInterfaceUtils.h References.h" ; then cp CtoJava.h 
> ErrorHandling.h JNIUtils.h ManagerInterfaceUtils.h 
> References.h /tmp/R.INSTALL.30363/SJava/inst/include ; fi mv 
> libRSNativeJava.so /tmp/R.INSTALL.30363/SJava/inst/libs
> Generating JNI header files from Java classes.
>    RForeignReference, RManualFunctionActionListener, 
> ROmegahatInterpreter & REvaluator
> *************
> Warning:
>     At present, to use the library you must set the 
>     LD_LIBRARY_PATH environment variable
>     to
>      
> /usr/lib/R/library/SJava/libs:/opt/lang/java/j2sdk1.4.2_01/jre
/lib/i386/client:/opt/lang/java/j2sdk1.4.2_>
01/jre/lib/i386:/opt/lang/java/j2sdk1.4.2_01/jre/../lib/i386:
>     or use one of the RJava.bsh or RJava.csh scripts
> *************
> ** libs
> gcc -I/usr/lib/R/include -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c ConverterExamples.c -o 
> ConverterExamples.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c Converters.c -o 
> Converters.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c Reflectance.c -o 
> Reflectance.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c REmbed.c -o REmbed.o gcc 
> -I/usr/lib/R/include -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c REmbedWin.c -o 
> REmbedWin.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c REval.c -o REval.o gcc 
> -I/usr/lib/R/include -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c RFunctionListener.c -o 
> RFunctionListener.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c RReferenceCall.c -o 
> RReferenceCall.o gcc -I/usr/lib/R/include -D_R_ 
> -I/usr/lib/R/include -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c RStoJava.c -o RStoJava.o 
> gcc -I/usr/lib/R/include -D_R_ -I/usr/lib/R/include 
> -I/usr/lib/R/include/R_ext 
> -I/tmp/R.INSTALL.30363/SJava/src/RSJava  -I. 
> -I/tmp/R.INSTALL.30363/SJava/inst/include  -IRSJava 
> -I/opt/lang/java/j2sdk1.4.2_01/include
> -I/opt/lang/java/j2sdk1.4.2_01/include/linux 
> -I/usr/local/include -D__NO_MATH_INLINES -mieee-fp  -fPIC  
> -O2 -m486 -fno-strength-reduce -g -c RtoJava.c -o RtoJava.o 
> gcc -shared -L/usr/local/lib -o SJava.so ConverterExamples.o 
> Converters.o Reflectance.o REmbed.o REmbedWin.o REval.o 
> RFunctionListener.o RReferenceCall.o RStoJava.o RtoJava.o 
> -L/tmp/R.INSTALL.30363/SJava/inst/libs
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386/client
> -L/opt/lang/java/j2sdk1.4.2_01/jre/lib/i386
> -L/opt/lang/java/j2sdk1.4.2_01/jre/../lib/i386
> -L/usr/lib/R/library/SJava/libs -lRSNativeJava -ljvm    
> ** R
> ** inst
> ** help
>  >>> Building/Updating help pages for package 'SJava'
>      Formats: text html latex example 
>   Array                             text    html    latex   example
>   Dollar                            text    html    latex   example
>   DotJavaSigs                       text    html    latex
>   DotjavaConfig                     text    html    latex
>   JClass                            text    html    latex   example
>   Java                              text    html    latex   example
>   JavaConstructor                   text    html    latex   example
>   JavaInit                          text    html    latex   example
>   JavaTerminate                     text    html    latex   example
>   OmegahatExpression                text    html    latex   example
>   RSJava.symbol                     text    html    latex   example
>   RtoJavaSig                        text    html    latex   example
>   expandClassName                   text    html    latex   example
>   foreignReference                  text    html    latex   example
>   getForeignReferences              text    html    latex   example
>   getJavaConverterDescriptions      text    html    latex   example
>   getJavaHandler                    text    html    latex   example
>   getMethods                        text    html    latex   example
>   getNumJavaConverters              text    html    latex   example
>   interfaceGenerator                text    html    latex   example
>   isJavaInitialized                 text    html    latex   example
>   javaConfig                        text    html    latex   example
>   javaHandlerGenerator              text    html    latex   example
>   javaIs                            text    html    latex   example
>   javaMatchFunctions                text    html    latex
>   javaSig                           text    html    latex   example
>   jdynamicCompile                   text    html    latex   example
>   mergePath                         text    html    latex   example
>   mergeProperties                   text    html    latex   example
>   omegahatReference                 text    html    latex   example
>   removeJavaConverter               text    html    latex   example
>   setConvertible                    text    html    latex   example
>   setJavaConverter                  text    html    latex   example
>   setJavaFunctionConverter          text    html    latex   example
>   setJavaHandler                    text    html    latex   example
>      missing link(s):  javaHandlerGenerator()
> Creating the symbolic link for libSJava.so in 
> /usr/lib/R/library/SJava/libs/
> * DONE (SJava)
> 
> * DONE (INSTALL)
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://www.stat.math.ethz.ch/mailman/listinfo> /r-help
> 
>




More information about the R-help mailing list