I had a problem with rJava in the latest version of R (3.4.1), Mac (10.12.5) and Java VM (1.8.0_131, x86_64 :)
Problem:
I try to follow this guide
scottdhoover.wordpress.com/2013/03/05/a-basic-rjava-example/
To run rJava in R.
Some code from r:
Library (rJava) .jinit (") .jclassPath () [1]" /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/java "
s <-.jnew ("java / lang / String", "Hello World!") .jcall (s, "I", "length") [1] 12
This actually works .. but when I try with my files:
.jaddClassPath ("/ Users / Camilo / Desktop / 20170711_Java2R") .jclassPath () [1] "/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/java" "/ Users / Camilo / Desktop / 20170711_Java2R "
myExchange <-.jnew ("myExchange") Error in .jnew ("myExchange"): java.lang.ClassNotFoundException
where the myExchange.java file is the same as in the manual and is located in the folder on the desktop.
What I've done:
Basically, I tried installing rJava from R and did not work. Then I follow two guides to be able to load the rJava package into R from the source
I follow this guide:
https://github.com/snowflakedb/dplyr-snowflakedb/wiki/Configuring-R-rJava-RJDBC-on-Mac-OS-X (for downloading rJava)
Where are both
R CMD javareconf /usr/libexec/java_home -V
It looks exactly as it should be.
To get rid of the OpenMP problem that people usually use, follow this guide:
http://thecoatlessprofessor.com/programming/openmp-in-r-on-os-x/#clang-before-3-4-0 (To get rid of the OpenMP problem that all people have).
Finally, I create a symbolic link using this code
sudo ln -f -s $(/usr/libexec/java_home)/jre/lib/server/libjvm.dylib /usr/local/lib
and I managed to install the library from R.
But! When I try it from the terminal, I get this error
ld: library not found for -lomp clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libjri.jnilib] Error 1 make[1]: *** [src/JRI.jar] Error 2 make: *** [jri] Error 2 ERROR: compilation failed for package 'rJava'
So me too: the library or the symbolic link should also be missing .. but there is no such file as in llvm (were solved in llvm with ld: library not found for -lomp )
I know that the error "ClassNotFoundExceptions" may be related to PATH, but it should be fine, because it was declared at the beginning.
btw, I also check the .R / Makevars file, which looks like
CC=/usr/local/clang4/bin/clang CXX=/usr/local/clang4/bin/clang++ LDFLAGS=-L/usr/local/clang4/lib
Any ideas how to solve them? Thank you in advance! Hope this is clear.