如何更改MacOS中的CurrentJDK符号链接

时间:2022-05-11 08:39:41

Currently in my Mac I have these JAVA versions:

目前在我的Mac上我有这些JAVA版本:


MyMac$ cd /Library/Java/JavaVirtualMachines

MyMac $ cd / Library / Java / JavaVirtualMachines

$ ls -la

$ ls -la

total 0

总共0

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

drwxr-xr-x 4根轮136 10月11日11:21。

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

drwxrwxr-x 5根轮170 10月11日11:21 ..

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

drwxr-xr-x 3根轮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

drwxr-xr-x 3根轮102 10月11日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:

我想要做的是将符号链接更改为指向JDK 7而不是JDK 6:


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

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

$ls -la

$ ls -la

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

drwxr-xr-x 11根轮374十月11:21。

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

drwxr-xr-x 10根轮340 10月11日11:21 ..

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

lrwxr-xr-x 1根轮10 17十一月11:21 1.4 - > CurrentJDK

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

lrwxr-xr-x 1根轮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根轮10 17十一月11:21 1.5 - > CurrentJDK

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

lrwxr-xr-x 1根轮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根轮10 17 Oct 11:21 1.6 - > CurrentJDK

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

lrwxr-xr-x 1根轮10 17 Oct 11:21 1.6.0 - > CurrentJDK

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

drwxr-xr-x 8根轮272 17 Oct 11:21 A

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

lrwxr-xr-x 1根轮1 17十一月11:21当前 - > A.

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

lrwxr-xr-x 1根轮52 17十月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

sudo rm CurrentJDK

rm: CurrentJDK: Operation not permitted

rm:CurrentJDK:不允许操作

Any ideas?

有任何想法吗?

Thank you!

谢谢!

2 个解决方案

#1


4  

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

El Capitan新功能:系统完整性保护(SIP),是导致此问题的原因。我必须先禁用SIP。

Follow these steps to disable SIP:

请按照以下步骤禁用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:

重启你的Mac。在OS X启动之前,按住Command-R并保持按住直到看到Apple图标和进度条。发布。这会引导您进入Recovery。从Utilities菜单中,选择Terminal。在提示符下键入以下内容,然后按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.

终端应显示SIP已禁用的消息。从apple菜单中,选择Restart。您可以按照上述步骤重新启用SIP,但请改用csrutil enable。

#2


1  

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

如果您正在运行OS X 10.11(El Capitan),则会出现一个名为“Rootless”的新功能,该功能会阻止编辑/ System /下的文件,除非安装程序等。您可以通过将JAVA_HOME环境变量设置为/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home来解决任何需要您更新CurrentJDK符号链接的问题。

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

如果您真的想要修改/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK符号链接,则可能必须禁用无根模式。您也可以尝试再次运行Java 7安装程序,但我不确定这是否可行

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

有关Rootless功能的更多信息,请访问:https://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really

#1


4  

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

El Capitan新功能:系统完整性保护(SIP),是导致此问题的原因。我必须先禁用SIP。

Follow these steps to disable SIP:

请按照以下步骤禁用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:

重启你的Mac。在OS X启动之前,按住Command-R并保持按住直到看到Apple图标和进度条。发布。这会引导您进入Recovery。从Utilities菜单中,选择Terminal。在提示符下键入以下内容,然后按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.

终端应显示SIP已禁用的消息。从apple菜单中,选择Restart。您可以按照上述步骤重新启用SIP,但请改用csrutil enable。

#2


1  

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

如果您正在运行OS X 10.11(El Capitan),则会出现一个名为“Rootless”的新功能,该功能会阻止编辑/ System /下的文件,除非安装程序等。您可以通过将JAVA_HOME环境变量设置为/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home来解决任何需要您更新CurrentJDK符号链接的问题。

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

如果您真的想要修改/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK符号链接,则可能必须禁用无根模式。您也可以尝试再次运行Java 7安装程序,但我不确定这是否可行

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

有关Rootless功能的更多信息,请访问:https://apple.stackexchange.com/questions/193368/what-is-the-rootless-feature-in-el-capitan-really