JavaVM Failed to load - java

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

Related

ERROR: configuration failed for package 'rJava'

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)

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.

Unable to install rjava in macbook pro 64-bit

I am trying to run the JDBC package. however, that requires that I install the rjava package. when i install rjava library, i get the following error:
library(rJava)
Unable to find any JVMs matching version "(null)".
No Java runtime present, try --request to install.
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/rJava.so
Reason: image not found
In addition: Warning message:
In system("/usr/libexec/java_home", intern = TRUE) :
running command '/usr/libexec/java_home' had status 1

Error: package ‘XLConnectJars’ could not be loaded in mac os

I got a problem when I called 'XLConnect' library in R.
Loading required package: XLConnectJars 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. Error : .onLoad failed in loadNamespace() for
'XLConnectJars', details: call: .jinit() error:
JNI_GetCreatedJavaVMs returned -1
Error: package ‘XLConnectJars’ could not be loaded
This error happened after I installed XLConnect and wrote library(XLconnect).
I googled this problem but there are no proper solution in my case.
I have already installed Java 8 and checked java location in terminal.
I run R in mac OS X (10.10.5)
Thank you for your help.
I solve the problem thanks to http://www.r-bloggers.com/getting-r-and-java-1-8-to-work-together-on-osx/

Why do I get "JNI_GetCreatedJavaVMs returned -1" error while loading the xlsx package in R?

I just downloaded xlsx package in R, but I just can't use the library. (On Mac)
> library(xlsx)
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.
Error : .onLoad failed in loadNamespace() for 'xlsx', details:
call: .jinit()
error: JNI_GetCreatedJavaVMs returned -1
Error: package or namespace load failed for ‘xlsx’
What am I doing wrong?
Make sure you have installed the dependencies:
xlsxjars
rJava
And, of course, if that does not work, verify you have the Java JDK installed in your mac: javac -version If not, just install it from here: https://java.com/en/download/faq/java_mac.xml

Categories