ERROR: configuration failed for package 'rJava' - java

Tried installing rJava on R but getting this error
install.packages("https://cran.r-project.org/src/contrib/Archive/rJava/rJava_0.9-9.tar.gz", repos = NULL, type="source")
Warning: running command 'sh ./configure.win' had status 127
ERROR: configuration failed for package 'rJava'
Installed jdk-18.0.1.1 and also set environment variables like this
JAVA_HOME: C:\Users\H481821\Downloads\openjdk-18.0.1.1_windows-x64_bin

I changed environment path from
JAVA_HOME: C:\Users\H481821\Downloads\openjdk-18.0.1.1_windows-x64_bin
to
C:\Users\H481821\Downloads\openjdk-18.0.1.1_windows-x64_bin\jdk-18.0.1.1
and executed R cmd
install.packages("rJava", type="win.binary")
(Use this to get compatible package to you R version so that you won't face version issues)

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?

How to install 'xlsx' in R

> library(**xlsx**)
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘xlsx’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JVM could not be found
In addition: Warning messages:
1: In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1
2: In fun(libname, pkgname) :
Cannot find JVM library 'NA/lib/server/libjvm.dylib'
Install Java and/or check JAVA_HOME (if in doubt, do NOT set it, it will be detected)
#then I tried 'writexlx' but then that began giving me error messages
>BiocManager::install('**writexslx**')
Bioconductor version 3.11 (BiocManager 1.30.10), R 4.0.2 (2020-06-22)
Installing package(s) 'writexslx'
Warning message:
package ‘writexslx’ is not available (for R version 4.0.2)
#I am not sure how to download this, please help
I evene tried to download jdk and that hasn't worked for me either.

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.

LoadLibrary failure RJava

I've been trying to load the qdap package, searching on here and troubleshooting, - realised Java couldn't be found. Uninstalled and downloaded Java - assuming I've done the correct 64 bit version as I am assuming I have RStudio 64 by checking
> R.Version()
$platform
[1] "x86_64-w64-mingw32"
I'm using "R version 3.4.3 (2017-11-30)" and Windows 10
Followed the advice here and set the following
Sys.setenv(JAVA_HOME='C:\\Program Files(x86)\\Java\\jre1.8.0_181')
ran this
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
}
Got this
find.java()
> find.java()
$`Security Baseline`
$`Security Baseline`$`1.4.2`
[1] "1.4.2_99"
$`Security Baseline`$`1.5.0`
[1] "1.5.0_99"
$`Security Baseline`$`1.6.0`
[1] "1.6.0_201"
$`Security Baseline`$`1.7.0`
[1] "1.7.0_191"
$`Security Baseline`$`1.8.0`
[1] "1.8.0_181"
Assumed this means Java can now be found. Also did this to check.
> system("java -version")
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) Client VM (build 25.181-b13, mixed mode, sharing)
So try to load rJava again.
> library(rJava)
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/grant/OneDrive/Documents/R/win-library/3.4/rJava/libs/x64/rJava.dll':
LoadLibrary failure: The specified module could not be found.
In addition: Warning message:package ‘rJava’ was built under R version 3.4.4
I've tried to follow the advice given in here and as shown above I know I have Java and a Java Run Time Environment and I have followed some of the suggested fixes already. I haven't done the PATH fixes as I'm not sure what exactly my PATH is, if it's wrong and how to change the PATH or put server in path. I've got as far as this but not sure how to decipher it.
> Sys.getenv("Path")[1] "C:\\Rtools\\bin;C:\\Program Files\\R\\R-3.4.3\\bin\\x64;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Users\\grant\\AppData\\Local\\Microsoft\\WindowsApps;"
I've also tried downloading and using Dependency Walker and didn't understand it.
Have I made an error in my assumptions? Is there an issue with my Path and if so how does Path get changed? Or is there anything else I can try?

JavaVM Failed to load

I'm trying to load the "openNLP" library in RStudio and I'm getting the following error. I get a similar error when I try to install the "RWeka" package.
How do I troubleshoot this?
library(openNLP)
Error : .onLoad failed in loadNamespace() for 'openNLPdata', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1
Error: package or namespace load failed for ‘openNLP’
JavaVM: requested Java version ((null)) not available. Using Java at "" instead.
JavaVM: Failed to load JVM: /bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
Found a solution to my issue. This is what worked for me. Please see below:
Launch R at the command line (to test the solution):
sudo R CMD javareconf
export LD_LIBRARY_PATH=$JAVA_LD_LIBRARY_PATH
LD_LIBRARY_PATH=$(/usr/libexec/java_home)/jre/lib/server: open -a RStudio
Now within RStudio:
install.packages("rJava", type = "source")
install.packages("openNLP")
require(rJava)
require(openNLP)
To launch RStudio from finder (El Capitan), you have to link libjvm.dylib to /usr/lib.
sudo ln -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib

Categories