thisismyname
thisismyname

Reputation: 31

Error message when trying to install rJava

I am trying to install rJava but it is not working. No matter which version of Java I install, I always get the same error. I already tried to install previous Java versions but that is not working. I also tried to set JAVA_HOME to the JDK folder but nothing seems to work. I am using Windows10. Code and error:

> install.packages("rJava")
Installing package into ‘C:/Users/x/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)

  There is a binary version available but the source version is later:
      binary source needs_compilation
rJava 0.9-12 0.9-13              TRUE

installing the source package ‘rJava’

trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-13.tar.gz'
Content type 'application/x-gzip' length 664898 bytes (649 KB)
downloaded 649 KB

* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
** using staged installation
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/src/jvm-w32'
C:/RBuildTools/3.5/mingw_64/bin/dlltool --as C:/RBuildTools/3.5/mingw_64/bin/as  --input-def jvm64.def --kill-at --dllname jvm.dll --output-lib libjvm.dll.a
C:/RBuildTools/3.5/mingw_64/bin/gcc  -O2 -c -o findjava.o findjava.c
C:/RBuildTools/3.5/mingw_64/bin/gcc  -s -o findjava.exe findjava.o
make: Leaving directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/src/jvm-w32'
Find Java...
  JAVA_HOME=C:/PROGRA~1/Java/JDK18~1.0_2/jre
=== Building JRI ===
  JAVA_HOME=C:/PROGRA~1/Java/JDK18~1.0_2/jre
  R_HOME=C:/PROGRA~1/R/R-36~1.3
JDK has no javah.exe - using javac -h . instead
Creating Makefiles ...
Configuration done.
make -C src JRI.jar
make[1]: Entering directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/jri/src'
C:/PROGRA~1/Java/JDK18~1.0_2/jre/bin/javac -h . -d . ../RList.java ../RBool.java ../RVector.java ../RMainLoopCallbacks.java ../RConsoleOutputStream.java ../Mutex.java ../Rengine.java ../REXP.java ../RFactor.java ../package-info.java
sh: C:/PROGRA~1/Java/JDK18~1.0_2/jre/bin/javac: No such file or directory
make[1]: *** [Makefile.all:41: org/rosuda/JRI/Rengine.class] Error 127
make[1]: Leaving directory '/cygdrive/c/Users/x/AppData/Local/Temp/RtmpQffZ3r/R.INSTALL35acefc1be9/rJava/jri/src'
make: *** [Makefile.all:19: src/JRI.jar] Error 2
**** WARNING: JRI could NOT be built
Set IGNORE=1 if you want to build rJava anyway.
ERROR: configuration failed for package 'rJava'
* removing 'C:/Users/x/Documents/R/win-library/3.6/rJava'
Warning in install.packages :
  installation of package ‘rJava’ had non-zero exit status

Thank you for your help!

Upvotes: 2

Views: 811

Answers (1)

Simon Urbanek
Simon Urbanek

Reputation: 13942

I would not recommend installing rJava from sources, because it is entirely unnecessary and compiling packages on Windows requires much better knowledge of tools, Java and your system. Since you are using Windows, please install rJava from CRAN using

install.packages("rJava", type="win.binary")

Upvotes: 5

Related Questions