-->

compile rJava on mac for Java 1.7

2019-08-04 04:53发布

问题:

Mac OS 10.8.4, R 3.1.0, rJava 0.9.6, RStudio 0.98

I would like to compile rJava from source so that it can run Java 1.7, ideally from within RStudio. Have read a number of websites giving advice about reconfiguring R for 1.7 and setting compiler flags (how to get rJava 0.9-3 to work on OS X 10.7.4 with Oracle Java 1.7?), but when I try install.packages("rJava",type='source'), I continue to run into:

... checking JNI data types... configure: error: One or more JNI types differ from the corresponding native type. You may need to use non-standard compiler flags or a different compiler in order to fix this. ERROR: configuration failed for package ‘rJava’

Any advice would be greatly appreciated.

UPDATE 1:

From previous postings, in my ~/.bashrc, I set

export PATH="$PATH:$JAVA_HOME/bin"

This got me past the JNI error, but now I am encountering

make -C src JRI.jar
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk/Contents/Home/jre/bin/javac -target 1.4 -source 1.4 -d . ../Mutex.java ../RBool.java ../RConsoleOutputStream.java ../REXP.java ../RFactor.java ../RList.java ../RMainLoopCallbacks.java ../RVector.java ../Rengine.java ../package-info.java
Error: Could not find or load main class com.sun.tools.javac.Main
make[2]: *** [org/rosuda/JRI/Rengine.class] Error 1
make[1]: *** [src/JRI.jar] Error 2
make: *** [jri] Error 2
ERROR: compilation failed for package ‘rJava’
* removing ‘/Library/Frameworks/R.framework/Versions/3.1/Resources/library/rJava’

Other websites suggest calling "unpack200 -r -v -l "" tools.pack tools.jar", but tools.pack doesn't appear to be included in jdk releases, anymore.

Any advice would be greatly appreciated! Thank you!

回答1:

I hope this answers your question: I am on mac os x 10.10.3 and I had issues with installing one of the packages that required rJava). I did the following and tried to reinstall from RStudio and it worked.

sudo R CMD javareconf
sudo find /Library/Frameworks/R.framework/Resources/etc -type f -exec chmod 664 "{}" \;