Could not find tools.jar. Please check that

原因:java_home指向了JRE路径

通过查看java_home发现第一条是jre(JavaAppletPlugin.plugin)的路径,第二条才是jdk(jdk1.8.0_311.jdk)的路径。

JavaAppletPlugin.plugin 是 JRE

根据docs.oracle.com中的描述,得出:JavaAppletPlugin.plugin 是 JRE。
Uninstalling the JRE on macOS

jdk1.8.0_311.jdk 是 JDK

根据docs.oracle.com中的描述,得出: jdk1.8.0_311.jdk 是 JDK。
Uninstalling the JDK on macOS

解决方法

一、查看JAVA_HOME

Many Java applications need to know the location of a $JAVA_HOME directory. The $JAVA_HOME on Mac OS X should be found using the /usr/libexec/java_home command line tool on Mac OS X 10.5 or later. On older Mac OS X versions where the tool does not exist, use the fixed path “/Library/Java/Home”.

Mac查看java_home的命令:
/usr/libexec/java_home -V

命令执行结果:

/usr/libexec/java_home -V
Matching Java Virtual Machines (2):
    1.8.311.11 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
    1.8.0_311 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

   
   
  • 1
  • 2
  • 3
  • 4
  • 5

结果解读:
前提,一台返修被格式化后的新电脑,通过oracle官网下载了jdk8 311版本并安装,且并没有装过其他版本。
执行命令后发现打印出两个虚拟机:JavaAppletPlugin.plugin和jdk1.8.0_311.jdk。

二、卸载JRE

卸载jre命令:

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane

   
   
  • 1
  • 2

三、再次查看java_home,确认是否正确

 /usr/libexec/java_home -V                                      
Matching Java Virtual Machines (1):
    1.8.0_311 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_311.jdk/Contents/Home

   
   
  • 1
  • 2
  • 3
  • 4

附件资料

资料一、卸载Java

MAC系统 JDK 卸载及彻底删除
▌1.删除运行路径和运行环境等

sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencesPanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java

▌2.删除当前版本的jdk

sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk
(注:不确定版本号先查看当前版本 ls /Library/Java/JavaVirtualMachines/ )

▌3.检查是否卸载成功

java -version

▌另外,官方资料如下:
如何在 Mac 上卸载 Java?
Depending on your installation, see the related link:

“卸载JRE”

“卸载JDK”

官方文档:
https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_install_faq.html#A1097743

资料二、卸载JRE(JavaAppletPlugin.plugin)

Uninstalling the JRE on macOS

To uninstall the JRE, you must have Administrator privileges and execute the remove commands either as root or by using the sudo(8) tool.

Remove one directory and one file (a symlink), as follows:

Navigate to /Library/Internet Plug-Ins and remove the JavaAppletPlugin.plugin directory.

Navigate to /Library/PreferencePanes and remove JavaControlPanel.prefpane.

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.

官方文档:《JRE的安装与卸载》
https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jre.html#A1096890

资料三、卸载JDK(jdk1.8.0_311.jdk)

Uninstalling the JDK on macOS

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:Foot1

/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk

   
   
  • 1

For example, to uninstall 8u6:

% rm -rf jdk1.8.0_06.jdk

   
   
  • 1

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.

官方文档:《JDK的安装与卸载》
https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#CHDBADCG

资料四:下载最新版的JDK并安装:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值