MAC 下删除Java版本的做法
参考了网上的很多教程,都是针对mac os旧版本的。目前我得环境是10.31.1 High Sierra,由于安装Eclipse+Android环境,运行后总是报告下面的错误:
java.lang.noclassdef found error: sun/misc/base64
但是并没有使用任何base64的方法。后来查询是java版本的错误
大致的原因是我用了jdk1.9,必须降到1.8才行。
查看java版本:
localhost:~ frankgogoland$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
所以必须将java版本降低。
正确的做法是删除9.0.1的jdk目录
localhost:~ frankgogoland$ cd /Library/Java/JavaVirtualMachines
localhost:JavaVirtualMachines frankgogoland$ ls
jdk-9.0.1.jdk jdk1.8.0_171.jdk
jdk1.7.0_80.jdk jdk1.8.0_172.jdk
localhost:JavaVirtualMachines frankgogoland$ sudo rm -rf jdk-9.0.1.jdk
然后在.bash_profile里面配置JAVA_HOME
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
参考文章:
https://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html#uninstall
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:*
/Library/Java/JavaVirtualMachines/jdk<major>.<minor>.<macro[_update]>.jdk
For example, to uninstall 7u6:
% rm -rf jdk1.7.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.
*The 7u4 and 7u5 releases were installed into a directory that does not follow this format. To uninstall 7u4 or 7u5, remove the 1.7.0.jdk directory from the same location.