Java tools.jar 似乎不在 Windows 8 上的 Android Studio 类路径中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27528652/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 04:31:05  来源:igfitidea点击:

tools.jar seems to be not in Android Studio classpath on Windows 8

javaandroidwindows-8android-studio

提问by Frank Martin

I installed Android Studio but it was giving me error that I need to install JDK but JDK was already installed. Then I realized it is asking to install 64bit version of JDK.

我安装了 Android Studio 但它给了我错误,我需要安装 JDK 但 JDK 已经安装。然后我意识到它要求安装 64 位版本的 JDK。

Anyway I just downloaded latest JDK 64bit version and set the following in Environment Variable but still Android Studio is giving error:

无论如何,我刚刚下载了最新的 JDK 64 位版本并在环境变量中设置了以下内容,但 Android Studio 仍然出现错误:

Error

错误

'tools.jar' seems to be not in Android Studio classpath.  
Please ensure JAVA_HOME points to JDK rather than JRE.

Following paths are set in my Windows 8.

在我的 Windows 8 中设置了以下路径。

Path in User Variables  
E:\Program Files\Java\jdk1.8.0_25\bin

JAVA_HOME in System Variables  
E:\Program Files\Java\jdk1.8.0_25

Path in System Variables  
E:\Program Files\Java\jdk1.8.0_25\bin

32bit JDK is installed on C drive while 64bit JDK is installed on E drive (as shown above). 32 bit JDK is not being used in any User or System Variables.

32位JDK安装在C盘,64位JDK安装在E盘(如上图)。任何用户或系统变量中均未使用 32 位 JDK。

I have also restarted the PC.

我也重新启动了PC。

How do I fix this issue?

我该如何解决这个问题?

采纳答案by Frank Martin

I tried everything I could but it didn't help. So I reinstalled Windows and installed Android Studio and now everything works.

我尽我所能,但没有帮助。所以我重新安装了 Windows 并安装了 Android Studio,现在一切正常。

And the irony is, there is no JAVA_HOME or JDK_HOME variable defined but it still works.

具有讽刺意味的是,没有定义 JAVA_HOME 或 JDK_HOME 变量,但它仍然有效。

回答by ArtOfCoding

In my case I've installed newest Java version without uninstalling older version first. After I've uninstalled the older Java version this error was gone.

就我而言,我安装了最新的 Java 版本,而没有先卸载旧版本。在我卸载了旧的 Java 版本之后,这个错误就消失了。

Also make sure your JAVA_HOME system variable is set properly, e.g.: Variable Name: JAVA_HOME Variable Value: C:\Program Files\Java\jdk1.8.0_31\

还要确保您的 JAVA_HOME 系统变量设置正确,例如:变量名称:JAVA_HOME 变量值:C:\Program Files\Java\jdk1.8.0_31\

And finally, that you've installed proper version for your OS, x86 or x64.

最后,您已经为您的操作系统、x86 或 x64 安装了正确的版本。

回答by beroduar

I had exactly the same problem. In my case I finally installed JRE to "C:\Program Files..." and the JDK to my default destination , which is "E:\Program Files..." It seems that the JDK and JRE cannot point to the same place for Android Studio .

我遇到了完全相同的问题。就我而言,我最终将 JRE 安装到“C:\Program Files...”,将 JDK 安装到我的默认目的地,即“E:\Program Files...” 看来 JDK 和 JRE 不能指向相同的Android Studio 的地方。

回答by John Blackberry

I had this same problem and was able to fix it after wasting about 3 hours:

我遇到了同样的问题,并且在浪费了大约 3 个小时后能够修复它:

Just copy tools.jar from %JAVA_HOME%\libto (Android Studio Root)\lib

只需将 tools.jar 从复制%JAVA_HOME%\lib(Android Studio Root)\lib

回答by Kaloglu

check your JAVA_HOME value!

检查您的 JAVA_HOME 值!

it should be like this

应该是这样的

E:\Program Files\Java\jdk1.8.0_25\jre

E:\Program Files\Java\jdk1.8.0_25\jre

回答by Indrabhushan

I had the same issue on windows 7 when I installed Android Studio. I had Jdk 8 on my system. So for me, copying the tools.jar from jdk\lib to androidstudio\lib worked. I found the tools.jar was missing from androidstudio's lib directory. I had set JAVA_HOME in user variable and JDK in system variable.

当我安装 Android Studio 时,我在 Windows 7 上遇到了同样的问题。我的系统上有 Jdk 8。所以对我来说,将 tools.jar 从 jdk\lib 复制到 androidstudio\lib 工作。我发现 androidstudio 的 lib 目录中缺少 tools.jar。我在用户变量中设置了 JAVA_HOME,在系统变量中设置了 JDK。

回答by David Vargas

First locate in your PC the route of your JDK (for instance: C:\Program Files\Java\jdk1.7.0_45)

首先定位在你的电脑你的JDK的路径(例如:C:\Program Files\Java\jdk1.7.0_45

then change the JAVA_HOMEvariable as follows:

然后JAVA_HOME按如下方式更改变量:

  1. Right-click the My Computer icon on your desktop and select Properties
  2. Click the Advanced tab
  3. Click the Environment Variables button
  4. Under System Variables, click New
  5. Enter the variable name as JAVA_HOME
  6. Enter the variable value as the installation path for the Java Development Kit
  1. 右键单击桌面上的“我的电脑”图标,然后选择“属性”
  2. 单击高级选项卡
  3. 单击环境变量按钮
  4. 在系统变量下,单击新建
  5. 输入变量名作为 JAVA_HOME
  6. 输入变量值作为 Java Development Kit 的安装路径

回答by Meta

I had the same error -- tools.jar seems to be not in Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.

我有同样的错误——tools.jar 似乎不在 Studio 类路径中。请确保 JAVA_HOME 指向 JDK 而不是 JRE。

I have a few Java JDKs downloaded. JAVA_HOME was pointing to C:\java\jdk1.7.0_45. When I switched to C:\java\jdk1.7.0_75, it worked. It makes no sense - both have lib/tools.jar. I did a jar tvf on each of the tools.jar files and they were fine. I ran java -version on each java & it ran ok. Dunno - makes no sense.

我下载了一些 Java JDK。JAVA_HOME 指向 C:\java\jdk1.7.0_45。当我切换到 C:\java\jdk1.7.0_75 时,它起作用了。这毫无意义——两者都有 lib/tools.jar。我对每个 tools.jar 文件都做了一个 jar tvf,它们很好。我在每个 java 上运行 java -version 并且运行正常。不知道 - 没有意义。

Platform: Windows 7 Professional - 64-bit v1.10.00.AG B11 Service Pack 1

平台:Windows 7 Professional - 64 位 v1.10.00.AG B11 Service Pack 1

回答by Andi

I installed jdk 1.8.0_51 64bit on Windows7. After that, no JAVA_HOME was defined, so I had to define it myself as described above, but it did not work unless I added a trailing backslash: D:\Programs\Java\jdk1.8.0_51\.

我在 Windows7 上安装了 jdk 1.8.0_51 64 位。在那之后,没有定义 JAVA_HOME,所以我必须按照上面的描述自己定义它,但它不起作用,除非我添加了一个尾随反斜杠: D:\Programs\Java\jdk1.8.0_51\

Without the backslash at the end it did not work.

如果最后没有反斜杠,它就不起作用。

回答by Suyash Jain

Just Copy the tools.jar from your jdk to Android lib directory.

只需将 tools.jar 从 jdk 复制到 Android lib 目录。