您的位置:首页 > 编程语言 > Java开发

娇滴滴的Mac,一次升级jdk导致的“事故”

2016-03-29 22:25 711 查看
起因
以前在windows上升级jdk1.7的时候,可以直接把原来的jdk卸载了,在安装jdk1.8,不知道能不能直接从1.7升级到1.8而不用卸载。现在在Mac上如初一辙,也这样干了,在网上搜了一堆乱七八糟的文章就开干了,然后就悲剧了。命令如下:

432 sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
433 sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefpane
434 cd /usr/bin/
435 ll
436 rm -f wsimport
437 sudo rm -f wsimport
438 jmc
439 find / -name JavaAppletPlugin.plugin
440 rm -rf /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
441 sudo find / -name JavaAppletPlugin.plugin
442 sudo rm -rf /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
443 /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
444 cd /System/Library/Java/Support/CoreDeploy.bundle/Contents/JavaAppletPlugin.plugin
445 ll
446 cd ..
447 ll
448 rm -rf JavaAppletPlugin.plugin/
449 sudo
450 sudo root
451 sudo -i
452 jmc
453 javac
454 java -version
455 java -version
456 javac
457 ll
458 java
459 sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
460 sudo rm -rf /Library/Preferences/
461 sudo -i

如果要卸载已经安装的jdk,请参考oracle官网上的reference,不要随便在网上找个教程就弄上了,因为rm -f是不能恢复的

Uninstalling the JDK
To uninstall the JDK, you must have Administrator privileges and execute the remove command either as root or by using the sudo(8) tool.
Navigate to/Library/Java/JavaVirtualMachines
and remove the directory whose name matches the following format.For example, to uninstall 8u6:
% rm -rf jdk1.8.0_06.jdk
Do not attempt to uninstall Java by removing the Java tools from/usr/bin
. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.

千万不要尝试着去删除/usr/bin/中的java*什么的

好吧,我已经做了!
会出现什么现象呢?你会发现很多变化,比如说开机界面上变成了英文什么的,关机弹窗变成了英文什么的,除此之外还有一些其他变化,如果你有幸误操作删除了系统自带的jdk1.6,你就会看到了。

那么如何恢复呢?
你可以和Apple客服掐架,当然一般是个女客服,也不会什么技术,你会发现掐了半个小时也没啥用,别问我为啥,因为我试过。浪费时间和电话费,那就去apple官网去看看Apple support什么的,也许有帮助。
进入 Apple官网,然后搜索,



进入如下页面



然后:
https://support.apple.com/kb/DL1572?viewlocale=zh_CN&locale=zh_CN

下载jdk,自行安装即可。

补充一句,开发用的jdk其实和Apple自己的jdk没啥关系,可以共存的,当然oracle的1.7和1.8也可以共存的,试着搜一下jEnv就知道了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Mac JDK