3
votes

Currently in my Mac I have these JAVA versions:


MyMac$ cd /Library/Java/JavaVirtualMachines

$ ls -la

total 0

drwxr-xr-x 4 root wheel 136 17 Oct 11:21 .

drwxrwxr-x 5 root wheel 170 17 Oct 11:21 ..

drwxr-xr-x 3 root wheel 102 14 Jul 22:52 1.6.0.jdk

drwxr-xr-x 3 root wheel 102 17 Oct 11:16 jdk1.7.0_79.jdk


What I am trying to do is change the symbolic link to point to JDK 7 instead of JDK 6:


$cd /System/Library/Frameworks/JavaVM.framework/Versions

$ls -la

drwxr-xr-x 11 root wheel 374 17 Oct 11:21 .

drwxr-xr-x 10 root wheel 340 17 Oct 11:21 ..

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.4 -> CurrentJDK

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.4.2 -> CurrentJDK

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.5 -> CurrentJDK

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.5.0 -> CurrentJDK

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.6 -> CurrentJDK

lrwxr-xr-x 1 root wheel 10 17 Oct 11:21 1.6.0 -> CurrentJDK

drwxr-xr-x 8 root wheel 272 17 Oct 11:21 A

lrwxr-xr-x 1 root wheel 1 17 Oct 11:21 Current -> A

lrwxr-xr-x 1 root wheel 52 17 Oct 11:21 CurrentJDK -> /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents


Unfortunately I cannot remove the link. I am getting an operation not permitted error:

sudo rm CurrentJDK

rm: CurrentJDK: Operation not permitted

Any ideas?

Thank you!

3

3 Answers

4
votes

El Capitan new feature: System Integrity Protection (SIP), was the cause of this problem. I had to disable SIP first.

Follow these steps to disable SIP:

Restart your Mac. Before OS X starts up, hold down Command-R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery. From the Utilities menu, select Terminal. At the prompt type exactly the following and then press Return:

csrutil disable

Terminal should display a message that SIP was disabled. From the apple menu, select Restart. You can re-enable SIP by following the above steps, but using csrutil enable instead.

1
votes

If you're running OS X 10.11 (El Capitan), there is a new feature called "Rootless" which prevents editing of files under /System/ except by installers and the like. You may be able to solve whatever problem is requiring you to update the CurrentJDK symlink just by setting the JAVA_HOME environment variable to /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home

If you truly want to modify that /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK symlink, you will likely have have to disable Rootless mode. You could also try running the Java 7 installer again, though I'm not certain that this will work

More information on the Rootless feature can be found here: https://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really

0
votes

Steps that worked on macOS Catalina 10.15.2 and RStudio 1.2.5036

Install Java 11.0.1 from here (requires free account):

https://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase11-5116896.html

Run javareconf

You probably need to run the command below, but RStudio seems not acknowledge the settings:

sudo R CMD javareconf 

Remove (if installed) and reinstall rJava from source

remove.packages("rJava") 
install.packages("rJava", type="source", repos="http://cran.rstudio.com")

Installing rJava from source seems to run a different configuration setup that will look for Java and it will display "checking Java support in R" as part of the output that seems accepted by RStudio.

Change ~/.Rprofile

This change to .Rprofile may also be necessary:

options(java.home="/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home")
Sys.setenv(DYLD_FALLBACK_LIBRARY_PATH="/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/")