Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin

bug:

IDEA 使用./gradlew build后报错:Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

其实就是/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home路径下(有资料说这个是 JRE 的路径)找不到tools.jar, tools.jar是在java JDK路径下。

解决方案:

mac使用如下命令快速找到java jdk路径:

 /usr/libexec/java_home -V

会显示两个路径:
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home路径和jdk路径/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

可以通过桌面前往-前往文件夹JDK路径,将tools.jar复制到/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

da3a50f0113d4eb1a670bacf8887e641.png

或使用sudo cp命令复制 (注意替换成自己的地址):

sudo cp /Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home/lib/tools.jar /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib

你可能感兴趣的:(Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin)