installing packages problems

i have updated my R studio version. Since i have done this i got problems in installing any package. I have macOS mojava 10.14.5 . R studio version 1.2.1335 , R version 3.6.1.
i have typed :
install.packages("xlsx" )

i got this message
"trying URL ''
Content type 'application/x-gzip' length 461752 bytes (450 KB)

downloaded 450 KB

The downloaded binary packages are in

and by writing :

so i got
"Error: package or namespace load failed for ‘xlsx’:
.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/':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/rJava/libs/, 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/
Reason: image not found "

I have tried to solve this problem since a while and didn't manage. Any help is appreciated

This problem is specific to packages that depend on Java, do you have java installed in your system? If so, try running this command in your system terminal and then restart Rstudio

sudo R CMD javareconf

Also, after updating R is good to update packages using checkBuilt

update.packages(checkBuilt = TRUE)

Thank you so much for answering me , yes i have updated the packages and i do have java before i wrote this post. so i don't know where does the problem come from.

i have typed the command you wrote here and i got this
Java interpreter : /usr/bin/java
Java version : 1.6.0_65
Java home path : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
conftest.c:1:10: fatal error: 'jni.h' file not found
#include <jni.h>
1 error generated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program

JAVA_HOME : /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
i think the problem is here

It seems like you have have an incompatible or corrupted version of Java, try installing this one.

Thats true . I have installed java version "1.6.0_65" from before and i have tried to uninstall it and install a new compatible one but i can't uninstall the old one .i have typed this in my consul
sudo rm -fr ~/library/Java/JavaVirtualMachines/jdk1.6.0_65.jdk
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Oracle/Java

i have tried also the oracle uninstall tool and instructions here:
but I'm still stuck with this java 1.6.0_65

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.