Error message when trying to install rJava - r

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!

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")

Related

Installing R package "validate" exits with error

I'm trying to install the package validate using install.package("validate"), but I get the following error message:
Installing package into ‘C:/Users/xxx/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
validate 0.9.3 1.0.1 TRUE
installing the source package ‘validate’
trying URL 'https://cran.rstudio.com/src/contrib/validate_1.0.1.tar.gz'
Content type 'application/x-gzip' length 1990096 bytes (1.9 MB)
downloaded 1.9 MB
* installing *source* package 'validate' ...
** package 'validate' successfully unpacked and MD5 sums checked
** using staged installation
** libs
*** arch - i386
C:/Program Files/R-Tools/mingw_32/bin/gcc -I"C:/PROGRA~1/R/R-3.6.1/include" -DNDEBUG -O3 -Wall -std=gnu99 -mtune=generic -c R_fdep.c -o R_fdep.o
sh: C:/Program: No such file or directory
make: *** [C:/PROGRA~1/R/R-3.6.1/etc/i386/Makeconf:208: R_fdep.o] Error 127
ERROR: compilation failed for package 'validate'
* removing 'C:/Users/xxx/Documents/R/win-library/3.6/validate'
* restoring previous 'C:/Users/xxx/Documents/R/win-library/3.6/validate'
Warning in install.packages :
installation of package ‘validate’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\xxx\AppData\Local\Temp\2\Rtmp08xXa8\downloaded_packages’
I've tried installing the package on my local machine and there I have no issues. This issues occurs when I try installing the package on a Azure-Cloud. Other packages install fine however. Also when I install the package using the "binary" option, it works fine... That is, howeverm, not the most recent version and there are some functionallities we want to use from the newest version.
Has anyone else encountered this problem and has a solution?
With the Help of user20650 I was able to find a solution.
We have an older version of R and R-Studio installed on our Cloud. This causes issues when installing packages with install.packages. Apparently only the newest source-file, but not the newest binary is considered. To overcome this I needed to download the binary manualy from cran. Then I installed the binary in R-Studio using Tools -> Install Packages... -> Install from: Package Archive file -> select Binary

Having issues in installation of RWeka

I have been trying to install RWeka for R through ipython notebook, but am getting errors. I have ubuntu 16.10
I have tried the following commands
sudo R CMD javareconf
sudo R
install.packages("rJava",type="source")
"Installing package into ‘/home/shahan/R/x86_64-pc-linux-gnu-
library/3.3’
(as ‘lib’ is unspecified)
Content type 'application/x-gzip' length 656615 bytes (641 KB)
downloaded 641 KB
* installing *source* package ‘rJava’ ...
* package ‘rJava’ successfully unpacked and MD5 sums checked
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
1 warning
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/jar fc JRI.jar org
libjri.so
make[2]: Leaving directory
'/tmp/RtmpDMwK9H/R.INSTALL4a885e7a4476/rJava/jri/src'
rm -f libjri.so
cp src/libjri.so libjri.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/javac -target 1.4 -source
1.4 -classpath src/JRI.jar -d examples examples/rtest.java
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
Note: examples/rtest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
/usr/lib/jvm/java-7-openjdk-amd64/jre/../bin/javac -target 1.4 -source
1.4 -classpath src/JRI.jar -d examples examples/rtest2.java
warning: [options] bootstrap class path not set in conjunction with -
source 1.4
Note: examples/rtest2.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 warning
make[1]: Leaving directory
'/tmp/RtmpDMwK9H/R.INSTALL4a885e7a4476/rJava/jri'
installing via 'install.libs.R' to /home/shahan/R/x86_64-pc-linux-gnu-
library/3.3/rJava
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (rJava)
The downloaded source packages are in
‘/tmp/RtmpPksP2c/downloaded_packages’ "
install.packages("RWeka")
Error in download.file(url, destfile, method, mode = "wb", ...) :
cannot download all files
In addition: Warning message:
In download.file(url, destfile, method, mode = "wb", ...) :
downloaded length 0 != reported length 415763
Warning in download.packages(pkgs, destdir = tmpd, available =
available, :
download of package ‘RWeka’ failed
* installing *source* package ‘RWekajars’ ...
** package ‘RWekajars’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
No man pages found in package ‘RWekajars’
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (RWekajars)
The downloaded source packages are in
‘/tmp/RtmpPksP2c/downloaded_packages’ "
Finally when i run
library("RWeka")
I get the below error. Any help would be appreciated.
"Error: package or namespace load failed for ‘RWeka’
Traceback:
1. library("RWeka")
2. stop(gettextf("package or namespace load failed for %s",
sQuote(package)),
. call. = FALSE, domain = NA)"
You could follow this instructions:
$ cd ~/
$ sudo -i
$ apt-get install r-cran-rjava
$ apt-get update
$ apt-get install openjdk-8-jdk
(version 8 seems to be bug free!)
$ rm -rf /usr/lib/jvm/default-java
(I personally did not have the default-java file, but you can check if it exists on your machine)
$ ln -s /usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/default-java
$ R CMD javareconf
$ R
$ install.packages(“RWeka”)

R Studio installing xlsx package

I'm trying to install the xlsx package using R Studio but I am encountering some problems. When the installation process starts I am asked the question "Package which is only available in source form, and may need compilation of C/C++/Fortran:‘rJava’ Do you want to attempt to install these from sources?" to which I reply "y".
The program then goes on to download 3 .tar.gz files. I have copied the full code below.
Problem is, I'm not sure what I need to do next in order to complete the installation? Any help is greatly appreciated.
> install.packages("xlsx")
also installing the dependencies ‘rJava’, ‘xlsxjars’
Package which is only available in source form, and may need compilation of C/C++/Fortran:
‘rJava’
Do you want to attempt to install these from sources?
y/n: y
installing the source packages ‘rJava’, ‘xlsxjars’, ‘xlsx’
trying URL 'https://cran.rstudio.com/src/contrib/rJava_0.9-7.tar.gz'
Content type 'application/x-gzip' length 711181 bytes (694 KB)
downloaded 694 KB
trying URL 'https://cran.rstudio.com/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
downloaded 9.0 MB
trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 KB)
downloaded 305 KB
* installing *source* package 'rJava' ...
** package 'rJava' successfully unpacked and MD5 sums checked
Generate Windows-specific files (src/jvm-w32) ...
make: Entering directory `/cygdrive/c/Users/davish/AppData/Local/Temp/RtmpmOuT4w/R.INSTALL456448961b13/rJ ava/src/jvm-w32'
dlltool --as as -m i386:x86-64 --as-flags --64 --input-def jvm64.def --kill- at --dllname jvm.dll --output-lib libjvm.dll.a
gcc -m64 -O2 -c -o findjava.o findjava.c
gcc -m64 -s -o findjava.exe findjava.o
make: Leaving directory `/cygdrive/c/Users/davish/AppData/Local/Temp/RtmpmOuT4w/R.INSTALL456448961b13/rJ ava/src/jvm-w32'
Find Java...
ERROR*> JavaSoft\{JRE|JDK} can't open registry keys.
ERROR: cannot find Java Development Kit.
Please set JAVA_HOME to specify its location manually
Warning: running command 'sh ./configure.win' had status 1
ERROR: configuration failed for package 'rJava'
* removing 'C:/Program Files/R/R-3.2.2/library/rJava'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/rJava_0.9- 7.tar.gz' had status 1
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
ERROR: dependency 'rJava' is not available for package 'xlsxjars'
* removing 'C:/Program Files/R/R-3.2.2/library/xlsxjars'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/xlsxjars_0.6.1 .tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsxjars’ had non-zero exit status
ERROR: dependencies 'rJava', 'xlsxjars' are not available for package 'xlsx'
* removing 'C:/Program Files/R/R-3.2.2/library/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.2.2\library" C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL/downloaded_packages/xlsx_0.5.7.tar .gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\davish\AppData\Local\Temp\Rtmp2FwjgL\downloaded_packages’
Please see the error :
ERROR*> JavaSoft\{JRE|JDK} can't open registry keys.
ERROR: cannot find Java Development Kit.
Please set JAVA_HOME to specify its location manually
solution : install jdk

downgrading a package in R

I recently installed the forecast package, using install.packages().
The latest version (6.1) has been successfully installed but I want to install the forecast package version 5.9. So I used :
install.packages('http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz', repos=NULL, type='source')
But when using library I get an error:
install.packages('http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz', repos=NULL, type='source')
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/Archive/forecast/forecast_5.9.tar.gz'
Content type 'application/x-gzip' length 156982 bytes (153 KB)
downloaded 153 KB
* installing *source* package 'forecast' ...
** package 'forecast' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
Warning: running command 'make -f "Makevars.win" -f "C:/PROGRA~1/R/R-32~1.1/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="forecast.dll" OBJECTS="calcBATS.o calcTBATS.o etsTargetFunction.o etsTargetFunctionWrapper.o etscalc.o etspolyroot.o makeBATSMatrices.o makeTBATSMatrices.o updateMatrices.o updateTBATSMatrices.o"' had status 127
ERROR: compilation failed for package 'forecast'
* removing 'C:/Users/.../Documents/R/win-library/3.2/forecast'
* restoring previous 'C:/Users/.../Documents/R/win-library/3.2/forecast'
Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE, copy.date = TRUE) :
problem copying C:\Users\...\Documents\R\win-library\3.2\00LOCK-forecast\forecast\libs\x64\forecast.dll to C:\Users\...\Documents\R\win-library\3.2\forecast\libs\x64\forecast.dll: Permission denied
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.1/bin/x64/R" CMD INSTALL -l "C:\Users\...\Documents\R\win-library\3.2" "C:/Users/.../AppData/Local/Temp/RtmpQzO3Zp/downloaded_packages/forecast_5.9.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/.../AppData/Local/Temp/RtmpQzO3Zp/downloaded_packages/forecast_5.9.tar.gz’ had non-zero exit status
Here is the way to install forecast version 5.9(Its not a problem if you have forecast 6.1 already installed,it would install 5.9 separately meaning that you would see two forecast packages in the installed packages ).
Go to the link https://cran.r-project.org/src/contrib/Archive/forecast/
Download forecast 5.9(just click on it,it would start downloading the file.
Now open the R studio,click on install packages and change install from to : Package archive File(and just browse it to the location of zip file).And your package would be installed.
While using the forecast package in my case it didnt work(the function that uses forecast package) when both the forecast package where loaded.So i use forecast 5.9 making sure that 6.1 isnt loaded.
Hope that helps

Install ggplot2 on opensuse 11.4

I'm trying to install ggplot2, however I get the following error:
trying URL
'http://cran.skazkaforyou.com/src/contrib/ggplot2_0.8.9.tar.gz'
Content type 'application/x-gzip' length 2074749 bytes (2.0 Mb) opened
URL
================================================== downloaded 2.0 Mb
* installing source package ‘plyr’ ...
** libs
sh: make: command not found
ERROR: compilation failed for package ‘plyr’
* removing
‘/home/jayron/R/x86_64-unknown-linux-gnu-library/2.12/plyr’
* installing source package ‘digest’ ...
** libs sh: make: command not found
sh: make: command not found ERROR: compilation failed for package
‘colorspace’
ERROR: dependencies ‘reshape’, ‘plyr’, ‘digest’, ‘colorspace’ are not
available for package ‘ggplot2’
* removing ‘/home/jayron/R/x86_64-unknown-linux-gnu-library/2.12/ggplot2’
The downloaded packages are in
‘/tmp/Rtmp0Sgoxp/downloaded_packages’
any help please?
Try the following code:
install.packages("ggplot2", repos = "http://cran.r-project.org")
You need development packages. Unless someone has packaged a recent Ggplot2 for opensuse, you will need to install these using (I think) zypper. The error message says you do not have 'make' on your system. It is likely that there will be more.
You need development packages. Until someone has packaged a recent ggplot2 for opensuse, which has not yet happened yet today (Jan 2014), you will need to be root to install these using zypper:
# zypper install r-base-devel
This package exists since opensuse 11.3.
The error message says you do not have 'make' on your system. If you only install 'make', it is likely that there will be more similiar errors. Thus you need to install all development tools needed for ggplot2. This can be done by root with
# zypper install -t pattern devel_C_C++

Resources