Problems with running rJava on Ubuntu 14.04 - java

after I recently failed to Upgrade to Ubuntu 14.10 the installer put back my system to the standard 14.04 configuration (That is somewhat what it said). Now I am facing problems using rJava in R together with the OpenStreetMap package.
The output of sudo update-alternatives --config java
is;
There are 3 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
3 /usr/lib/jvm/jre1.7.0/jre1.7.0_21/bin/java 3 manual mode
I then run: sudo R CMD javareconf:
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
Java interpreter : /usr/bin/java
Java version : 1.7.0_75
Java home path : /usr/lib/jvm/java-7-openjdk-amd64/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI progam
detected JNI cpp flags : -I$(JAVA_HOME)/../include
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/usr/lib/jvm/java-7-openjdk-amd64/jre/../include -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o conftest.so conftest.o -L/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server -ljvm -L/usr/lib/R/lib -lR
JAVA_HOME : /usr/lib/jvm/java-7-openjdk-amd64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /usr/lib/R
Done.
However, if I start working in R I get the message:
/usr/lib/R/etc/ldpaths: line 1: :/usr/lib/jvm/java-7-openjdk-amd64/jre: No such file or directory
OpenStreetMap throws the following error:
java.lang.NullPointerException
at edu.cens.spatial.RTileController.getTileValues(RTileController.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at RJavaTools.invokeMethod(RJavaTools.java:386)
Error in osmtile(x, y, zoom, type) : could not obtain tile: 39746 1 2
What can I do? The script I use is unchanged for since long time and worked fine before (I am not sure whether the failed upgrade is related to the error)

Related

sudo R CMD javareconf solution not working

I am trying to run rJava in RStudio but without success:
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
Using the common solution for rJava issues, 'sudo R CMD javareconf' doesn't work and gives me this ouput:
Java interpreter : /usr/bin/java
Java version : 11.0.6
Java home path : /Library/Java/JavaVirtualMachines/jdk-11.0.6.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 : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home/include/darwin -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
clang-7: warning: no such sysroot directory: '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk' [-Wmissing-sysroot]
In file included from conftest.c:1:
/Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home/include/jni.h:39:10: fatal error:
'stdio.h' file not found
#include <stdio.h>
^~~~~~~~~
1 error generated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-11.0.6.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
Did anyone come across this error before and knows how to tackle it?
I had a problem like this with a coworker recently after they upgraded to Catalina. My solution was to install the offending version of JDK again. It looks like your system has confusion between 11.0.6 and 11.0.1.
Go to this page:
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase11-5116896.html
Download and install 11.0.1
sudo R CMD javareconf
sudo Rstudio # elevate privs
install.packages("rJava")
If that doesn't work, try again from step 2, but with 11.0.6 from https://www.oracle.com/technetwork/java/javase/overview/index.html
What did the trick in the end was to show Rstudio where to look as identified by user Rmadillo here:
github.com/rstudio/rstudio/issues/2254
Just run this each time before using the rJava package.

rJava is not loading in R

So basically this is the error I'm having when calling rJava:
library(rJava)
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
Below are some of the R & Terminal scripts that I ran while tackling the problem:
1) This returned error as well
$ sudo R CMD javareconf
Password:
Java interpreter : /usr/bin/java
Java version : 13.0.1
Java home path : /Library/Java/JavaVirtualMachines/jdk-13.0.1.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 : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
detected JNI linker flags : -L. -ljvm
clang -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/include/darwin -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o conftest.so conftest.o -L. -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: library not found for -ljvm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [conftest.so] Error 1
Unable to compile a JNI program
JAVA_HOME : /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
2)
> Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home')
> dyn.load('/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
3)
$ sudo ln -f -s $(/usr/libexec/java_home)/lib/server/libjvm.dylib /usr/local/lib
In case this helps:
> Sys.getenv("DYLD_FALLBACK_LIBRARY_PATH")
[1] "/Library/Frameworks/R.framework/Resources/lib:/Users/paulwoo/lib:/usr/local/lib:/usr/lib:::/lib:/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"
> Sys.getenv("DYLD_LIBRARY_PATH")
[1] "/Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home/lib/server"
Yet none of these solved the problem. I have reinstalled rJava package several times as well. My best guess is that this has something to do with mismatch between the versions, but I have no idea what to do.
Any other suggestions?
Use the OSX uninstaller tool to nuke your current install of JDK.
Reinstall (Open)JDK
brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk13-openj9-large
Then reconfigure RJava:
sudo R CMD javareconf
This should do the trick.

rJava jdk incongruity

I'm running Mac High Sierra 10.13.6, R version 3.5.2. I am unable to load my rJava package after installation in the R Console.
In R, running install('rJava') and then library(rJava) returns:
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.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/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.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
I know that my jdk's should have the same version, so I've made this fix, but for some reason the deleted jdk-11.0.1.jdk keeps popping up in the error message.
Also, I have this written in my .bash_profile:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home"
which is the same output location when running /usr/libexec/java_home in terminal.
Finally, I've run sudo R CMD javareconf multiple times in terminal. Here's the output from that:
Password:
Java interpreter : /usr/bin/java
Java version : 1.8.0_201
Java home path : /Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre
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 : -I$(JAVA_HOME)/../include - I$(JAVA_HOME)/../include/darwin
detected JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
/usr/local/Cellar/gcc#5/5.5.0_2/bin/gcc-5 -
I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/../include -I/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/../include/darwin -I/usr/local/include -fPIC -Wall -g -O2 -c conftest.c -o conftest.o
/usr/local/Cellar/gcc#5/5.5.0_2/bin/gcc-5 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/Cellar/gcc#5/5.5.0_2/lib -o conftest.so conftest.o -L/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre/lib/server -ljvm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
ld: warning: text-based stub file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation.tbd and library file /System/Library/Frameworks//CoreFoundation.framework/CoreFoundation are out of sync. Falling back to library file for linking.
JAVA_HOME :
/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/jre
Java library path: $(JAVA_HOME)/lib/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/darwin
JNI linker flags : -L$(JAVA_HOME)/lib/server -ljvm
Updating Java configuration in /Library/Frameworks/R.framework/Resources
Done.
Any help would be valuable. Thank you!

Issues in Installing RWeka in R (Ubuntu 16.04)

I want to install Fselector package in which RWeka is needed but on installing RWeka it throughs me following error:
Error : .onLoad failed in loadNamespace() for 'RWeka', details:
call: .jcall("java/lang/System", "V", "setOut", out)
error: method setOut with signature (Ljava/io/PrintStream;)V not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/gaurav/R/x86_64-pc-linux-gnu-library/3.3/RWeka’
Warning in install.packages :
installation of package ‘RWeka’ had non-zero exit status
ERROR: dependency ‘RWeka’ is not available for package ‘FSelector’
* removing ‘/home/gaurav/R/x86_64-pc-linux-gnu-library/3.3/FSelector’
Warning in install.packages :
installation of package ‘FSelector’ had non-zero exit status
I searched about the same and did some modification with jdk, updated the path to jdk/bin in bashrc, but nothing worked.
Session Info
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS
locale:
[1] LC_CTYPE=en_IN.UTF-8 LC_NUMERIC=C LC_TIME=en_IN.UTF-8
[4] LC_COLLATE=en_IN.UTF-8 LC_MONETARY=en_IN.UTF-8 LC_MESSAGES=en_IN.UTF-8
[7] LC_PAPER=en_IN.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_IN.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_0.12.12 digest_0.6.12 mime_0.5 grid_3.3.3 plyr_1.8.4
[6] R6_2.2.2 xtable_1.8-2 gtable_0.2.0 scales_0.4.1 ggplot2_2.2.1
[11] rlang_0.1.1 lazyeval_0.2.0 brew_1.0-6 tools_3.3.3 munsell_0.4.3
[16] Rook_1.1-1 shiny_1.0.4 httpuv_1.3.5 colorspace_1.3-2 htmltools_0.3.6
[21] tibble_1.3.3
Can anyone help me in this.
Thanks in advance
Update 1:#Nanov, I followed the steps but still i received same error, I have openjdk 8 and updated the path in bashrc, & when I used "sudo R CMD javareconf" I get below information:
gaurav#gaurav-ds:~$ sudo R CMD javareconf
Java interpreter : /usr/lib/jvm/java-8-oracle/jre/bin/java
Java version : 1.8.0_131
Java home path : /usr/lib/jvm/java-8-oracle/jre
Java compiler : not present
Java headers gen.:
Java archive tool:
trying to compile and link a JNI program
detected JNI cpp flags :
detected JNI linker flags : -L/usr/lib -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time-D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.oconftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
/usr/lib/R/etc/Makeconf:132: recipe for target 'conftest.o' failed
make: *** [conftest.o] Error 1
Unable to compile a JNI program.
JAVA_HOME : /usr/lib/jvm/java-8-oracle/jre
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
sudo apt-get install r-cran-rjava
sudo apt-get install openjdk-8-jdk
sudo rm -rf /usr/lib/jvm/default-java
sudo ln -s /usr/lib/jvm/java-8-openjdk-amd64/ /usr/lib/jvm/default-java
sudo R CMD javareconf
sudo R
install.packages(“RWeka”)
Better install openjdk-8-jdk, because in the newest version -9- is bug.

rJava not installing in ubuntu 14.04

I am trying to install rJava for my R enviroment.
I have tried this
$sudo locate libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so
$sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so /usr/lib/
$sudo R CMD javareconf
Java interpreter : /usr/lib/jvm/default-java/jre/bin/java
Java version : 1.7.0_79
Java home path : /usr/lib/jvm/default-java
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/usr/lib -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
#include <jni.h>
^
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program
JAVA_HOME : /usr/lib/jvm/default-java
Java library path:
JNI cpp flags :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.
In R side its showing this error
install.packages("rJava")
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.
If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.
ERROR: configuration failed for package ‘rJava’
* removing ‘’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
I believe this is the cause of the problem I some how installed two java environments and this is interfering with my rjava installation. How can i solve this.

Categories