Cannot install xlsx package for R - java

Cannot install R package xlsx.
I have previously used the package on other PCs and had no trouble with it whatsoever, but am having difficulty with a new PC. From what I can tell the issue is something to do with Java. Currently tried:
Downloading Java Development Kit
Downloading JRE
Editing environment variables to point to the right Java (for both of the above)
Running through the R console (both 32 and 64 bit)
Uninstalling and reinstalling Rstudio / R
install.packages("xlsx")
`Installing package into ‘C:/Users/Fred Goktas/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is later:
binary source needs_compilation
xlsx 0.5.7 0.6.1 FALSE
installing the source package ‘xlsx’
trying URL 'https://cran.rstudio.com/src/contrib/xlsx_0.6.1.tar.gz'
Content type 'application/x-gzip' length 315441 bytes (308 KB)
downloaded 308 KB
* installing source package 'xlsx' ...
** package 'xlsx' successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
* installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/rJava/libs/i386/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/Fred Goktas/Documents/R/win-library/3.3/xlsx'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-33~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\Fred Goktas\Documents\R\win-library\3.3" C:\Users\FREDGO~1\AppData\Local\Temp\RtmpYLz0xk/downloaded_packages/xlsx_0.6.1.tar.gz' had status 1
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
Package should install without any troubles.

Unless you have no compelling reason to use xlsx, I would suggest you consider readxl because it has no external dependencies.

Related

Cant download package xlsx or rjava R

I am trying to download the xlsx package in R but get the following error message:
Error: package or namespace load failed for 'xlsx':
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/X/Documents/R/win-library/3.6/xlsx'
Warning in install.packages :
installation of package ‘xlsx’ had non-zero exit status
I have also tried to download rjava, but get this error message:
ERROR*> JavaSoft\{JRE|JDK} can't open registry keys.
ERROR: cannot find Java Development Kit.
Please set JAVA_HOME to specify its location manually
ERROR: configuration failed for package 'rJava'
* removing 'C:/Users/X/Documents/R/win-library/3.6/rJava'
* restoring previous 'C:/Users/X/Documents/R/win-library/3.6/rJava'
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
I have reinstalled Java to my computer, with the same architecture s my computer and R (64-bit), which most of the help online says that I should try out. Have anyone experienced the same problem?

Error in i.p(...) : installation of package ... had non-zero exit status

I try to install the RDRPOSTagger package through devtools.
devtools::install_github("bnosac/RDRPOSTagger", build_vignettes = TRUE)
Downloading GitHub repo bnosac/RDRPOSTagger#master
WARNING: Rtools is required to build R packages, but is not currently installed.
Please download and install Rtools 3.5 from http://cran.r-project.org/bin/windows/Rtools/.
√ checking for file 'C:\Users\X1\AppData\Local\Temp\RtmpUD2iwv\remotes70c59a944c1\bnosac-RDRPOSTagger-af51e38/DESCRIPTION' ...
- preparing 'RDRPOSTagger': (1.1s)
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'RDRPOSTagger_1.1.tar.gz'
Installing package into ‘C:/Users/X1/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *source* package 'RDRPOSTagger' ...
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
converting help for package 'RDRPOSTagger'
finding HTML links ... done
rdr_add_space_around_punctuations html
rdr_available_models html
rdr_model html
rdr_pos html
** building package indices
** installing vignettes
** testing if installed package can be loaded
*** arch - i386
Error: package or namespace load failed for 'rJava':
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures.
Error : package 'rJava' could not be loaded
Error: loading failed
Execution halted
*** arch - x64
ERROR: loading failed for 'i386'
* removing 'C:/Users/X1/Documents/R/win-library/3.5/RDRPOSTagger'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/X1/AppData/Local/Temp/RtmpUD2iwv/file70c8917649/RDRPOSTagger_1.1.tar.gz’ had non-zero exit status
Session Info:
sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Java version on my CPU: java 10.0.2 64 bit
I try to use the qdap package which also needs rJava and this works just fine.
Error : package 'rJava' could not be loaded
This package is not loaded because JAVA_HOME is not set.
It can be done by first installing depending on your R (32 bit or 64 bit), Java 32 bit or 64 bit.
Download java from here: https://www.java.com/en/download/
Using this find JAVA_HOME address:
find.java <- function() {
for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment",
"Software\\JavaSoft\\Java Development Kit")) {
hive <- try(utils::readRegistry(key, root, 2),
silent = TRUE)
if (!inherits(hive, "try-error"))
return(hive)
}
hive
}
Load find.java and you will find the address for JAVA_HOME. Enter that address here:
Sys.setenv(JAVA_HOME='C:\\Your\\Java\\Directory')
library(rJava)
That should load the package rJava.
ERROR: loading failed for 'i386'
This error is maybe because you have downloaded both version of R (32 bit and 64 bit) and devtools tries to build for both of them.
You can use this:
devtools::install_github("mne-tools/mne-r", INSTALL_opts=c("--no-multiarch"))
I was also getting the similar type of error and after searching through I came across this solutions which worked for me.

Build OpenCV from source on Ubuntu 16.04, but failed to generate Java bindings

I am trying to build OpenCV from source on Ubuntu to within a Java application, but when during processing make commanded, when it reaches to generate Java bindings it fails with the following error:
[ 90%] Generate files for Java bindings Traceback (most recent call
last): File
"/home/adil/Desktop/opencv/opencv/modules/java/generator/../generator/gen_java.py",
line 1093, in
copy_java_files(java_files_dir, target_path) File "/home/adil/Desktop/opencv/opencv/modules/java/generator/../generator/gen_java.py",
line 1042, in copy_java_files
package_path = 'org/opencv/' + module NameError: global name 'module' is not defined
modules/java_bindings_generator/CMakeFiles/gen_opencv_java_source.dir/build.make:430:
recipe for target 'CMakeFiles/dephelper/gen_opencv_java_source' failed
make[2]: * [CMakeFiles/dephelper/gen_opencv_java_source] Error 1
CMakeFiles/Makefile2:2799: recipe for target
'modules/java_bindings_generator/CMakeFiles/gen_opencv_java_source.dir/all'
failed make[1]: *
[modules/java_bindings_generator/CMakeFiles/gen_opencv_java_source.dir/all]
Error 2 Makefile:160: recipe for target 'all' failed make: *** [all]
Error 2
I have installed every possible lib suggested on the Google and OpenCV website, nothing was solved the problem.
So what causes this error, and how solve?
Note: I have Java-9 installed on my machine.

library(rJava) does not load after installing package

I have been reading up on examples and cannot figure out the solution. I also had IT come by and they can't figure out why it isn't working also.
I am trying to use the 'rJava' package from R.
I uninstalled RStudio and R to get the latest versions.
Here is what I did:
install.packages('rJava')
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-9.zip'
Content type 'application/zip' length 720033 bytes (703 KB)
downloaded 703 KB
package ‘rJava’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Temp\RtmpSyCpeu\downloaded_packages
Then when I run below, this is what shows up:
library(rJava)
This same error message happens after I uninstalled RStudio and R.
When I click ok, below is the error that comes up.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/nicknaue/Documents/R/R-
3.4.3/library/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
To try and solve for this, we downloaded the latest Java and also got a file from another program with the same name: jvm.dll and put it in the same file path. No luck also.
Has anyone come across this issue before?
Also, something weird, I have another computer where I tried this on and no errors came up.
I know there have been posts on this but I feel like I have tried everything at this point.
Figured out the answer from this link: Unable to load rJava on R
The issue was that I had 64-bit R and 32 bit Java. The two were not compatible before. You need 64 bit Java in order to run rJava if you have 64 bit R.

Cant install openNLPdata_1.5.3-1.tar.gz on R/RStudio

I'm trying install openNLPdata_1.5.3-1 but I cant get it done. I installed successfully the rJava dependencies.
I am getting this error:
install.packages("C:/Users/André Almeida/Dropbox/Tese de Mestrado/R/packages/openNLPdata_1.5.3-1.tar.gz", repos = NULL, type = "source")
* installing *source* package 'openNLPdata' ...
** package 'openNLPdata' successfully unpacked and MD5 sums checked
**********************************************
WARNING: this package has a configure script
It probably needs manual configuration
**********************************************
** R
** inst
** preparing package for lazy loading
** help
No man pages found in package 'openNLPdata'
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: library.dynam("rJava", pkgname, libname)
error: DLL 'rJava' not found: maybe not installed for this architecture?
Error: loading failed
Execution halted
*** arch - x64
Error occurred during initialization of VM
Unable to load native library: Can't find dependent libraries
ERROR: loading failed for 'i386', 'x64'
* removing 'C:/Program Files/R/R-3.1.0/library/openNLPdata'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.0/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.1.0\library" "C:/Users/ANDRAL~1/Dropbox/TESEDE~1/R/packages/openNLPdata_1.5.3-1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/ANDRAL~1/Dropbox/TESEDE~1/R/packages/openNLPdata_1.5.3-1.tar.gz’ had non-zero exit status
I got the same error.
So it all goes down to rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘/Users/alexanderkozhevin/anaconda/lib/R/library/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
ERROR: dependency ‘rJava’ is not available for package ‘openNLPdata’
* removing ‘/Users/alexanderkozhevin/anaconda/lib/R/library/openNLPdata’
Warning in install.packages :
installation of package ‘openNLPdata’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/1x/h3k01wvs1qq4sm4k_5z8qg9w0000gn/T/RtmpIrOVhy/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done

Categories