简体   繁体   English

设置JAVA_HOME变量时出现问题

[英]Problems setting the JAVA_HOME variable

So I just downloaded Android Studio, and am trying to set the JAVA_HOME variable so I can run it. 因此,我刚刚下载了Android Studio,并尝试设置JAVA_HOME变量,以便可以运行它。 I'm using windows 8 and have followed all the instructions I've been able to find to no avail... went to advanced system settings > environment variables and then set the JAVA_HOME variable with the value containing my path to jre7. 我正在使用Windows 8,并且已按照我能找到的所有说明无效...转到高级系统设置>环境变量,然后使用包含我的jre7路径的值设置JAVA_HOME变量。 I've double checked the path a million times, I don't see anything wrong with it(C:\\Program Files (x86)\\Java\\jre7). 我已经对该路径进行了100百万次仔细检查,但没有发现任何错误(C:\\ Program Files(x86)\\ Java \\ jre7)。 I know the variable name is right, and I know that windows is excepting the variable, I've even restarted twice. 我知道变量名正确,而且我知道Windows除了变量之外,我什至重启了两次。 What am I doing wrong here? 我在这做错了什么? The only thing I can think of that may be wrong is the fact that I'm pointing to a jre instead of a jdk, but I've always thought that both worked... anyway, the exact error message I get when I try to open Android Studio says: 我唯一能想到的可能是错误的是我指的是jre而不是jdk,但我一直认为这两种方法都有效...无论如何,当我尝试时我得到的确切错误信息打开Android Studio说:

No JVM installation found. 未找到JVM安装。 Please install a 64-bit JDK. 请安装64位JDK。 If you already have a JDK installed, define a JAVA_HOME variable in Computer > System Properties > System Settings > Environment Variables. 如果已安装JDK,请在计算机>系统属性>系统设置>环境变量中定义JAVA_HOME变量。

If a jre doesn't work in place of a jdk, then how do I go about getting one? 如果一个jre不能代替jdk,那么我该如何获得jdk呢? I know nothing about Java I just want to get into this IDE and play around with Android. 我对Java一无所知,我只想进入这个IDE并使用Android。

No JVM installation found. 未找到JVM安装。 Please install a 64-bit JDK. 请安装64位JDK。

It's asking for a 64-bit JDK. 它要求一个64位的JDK。 You say your environment variable is pointing at the following directory: 您说您的环境变量指向以下目录:

C:\\Program Files (x86)\\Java\\jre7 C:\\ Program Files(x86)\\ Java \\ jre7

There's two things wrong here. 这里有两件事是错的。 First, you're pointing to a JRE - Java Runtime Environment. 首先,您指向JRE - Java运行时环境。 This is not a JDK - Java Development Kit. 不是 JDK -Java开发工具包。 The JRE is for running Java applications; JRE用于运行Java应用程序; the JDK is for developing Java applications. JDK用于开发 Java应用程序。 There's a significant difference there. 那里有很大的不同。

Secondly, as others have mentioned, you're pointing the environment variable to the 32-bit version. 其次,正如其他人所提到的,您将环境变量指向32位版本。 You need a 64-bit JDK. 您需要一个64位JDK。 This will be installed at C:\\Program Files\\Java\\jdk1.7.0_XX or similar, by default. 默认情况下,它将安装在C:\\Program Files\\Java\\jdk1.7.0_XX或类似C:\\Program Files\\Java\\jdk1.7.0_XX

You can acquire a JDK installation from Oracle . 您可以从Oracle获得JDK安装。

Here is the official installation instructions - http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html 这是官方安装说明 - http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html

The important thing is 重要的是

  1. Set JAVA_HOME to the location where jre or jdk is installed JAVA_HOME设置为安装jre或jdk的位置

  2. Add %JAVA_HOME%/bin to your path variable. %JAVA_HOME%/bin添加到您的路径变量。

Make sure you add these to "System Variables" and not in "User variables for xxx" 确保将这些添加到“系统变量”而不是“xxx的用户变量”中

By default, c:\\Program Files (x86) (environment variable ProgramFiles(x86) )is used for 32-bit installations. 默认情况下, c:\\Program Files (x86) (环境变量ProgramFiles(x86) )用于32-bit安装。 64-bit installations use c:\\Program Files (environment variable ProgramFiles ). 64-bit安装使用c:\\Program Files (环境变量ProgramFiles )。

When I open a cmd box on my Windows 7 64-bit , I can issue the " set " command to get 当我在Windows 7 64-bit上打开一个cmd框时,我可以发出“ set ”命令来获取

ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files

This should be similar under Windows 8. 在Windows 8下应该类似。

No JVM installation found. Please install a 64-bit JDK

This is looking for a 64bit version of the java JDK. 这是寻找64位版本的Java JDK。

C:\\Program Files (x86) is the x86 not 64bit. C:\\Program Files (x86)是x86而不是64位。

Click the link below and make sure to download the x64 version. 单击下面的链接,并确保下载x64版本。

Java SE Development Kit 7 Downloads Java SE Development Kit 7下载

Then the folder path should be 那么文件夹路径应该是

C:\Program Files\Java\jre7

Try runing Android Studio as administrator after setting the JAVA_HOME variable! 设置JAVA_HOME变量后,尝试以管理员身份运行Android Studio! It worked for me... 它对我有用...

Same thing happened to me and it turns out that all I had to do was unblock the file. 我也发生了同样的事情,事实证明,我要做的就是取消阻止文件。 Go to the file properties and at the bottom where it tells you it's from another computer and is blocked, just unblock it. 转到文件属性,然后在底部告诉您它来自另一台计算机并且已被阻止,只需取消阻止即可。 This may not be true for everyone but it probably is if the path code is exactly what it should be and still isn't working. 这可能并非对每个人都适用,但可能是因为路径代码恰如其应,仍然无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM