Problems setting the JAVA_HOME variable

筅森魡賤 提交于 2021-02-08 05:19:11

问题


So I just downloaded Android Studio, and am trying to set the JAVA_HOME variable so I can run it. 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. I've double checked the path a million times, I don't see anything wrong with it(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. 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:

No JVM installation found. Please install a 64-bit JDK. If you already have a JDK installed, define a JAVA_HOME variable in Computer > System Properties > System Settings > Environment Variables.

If a jre doesn't work in place of a jdk, then how do I go about getting one? I know nothing about Java I just want to get into this IDE and play around with Android.


回答1:


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

It's asking for a 64-bit JDK. You say your environment variable is pointing at the following directory:

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

There's two things wrong here. First, you're pointing to a JRE - Java Runtime Environment. This is not a JDK - Java Development Kit. The JRE is for running Java applications; the JDK is for developing Java applications. There's a significant difference there.

Secondly, as others have mentioned, you're pointing the environment variable to the 32-bit version. You need a 64-bit JDK. This will be installed at C:\Program Files\Java\jdk1.7.0_XX or similar, by default.

You can acquire a JDK installation from Oracle.




回答2:


Here is the official installation instructions - 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

  2. Add %JAVA_HOME%/bin to your path variable.

Make sure you add these to "System Variables" and not in "User variables for xxx"




回答3:


By default, c:\Program Files (x86) (environment variable ProgramFiles(x86))is used for 32-bit installations. 64-bit installations use c:\Program Files (environment variable ProgramFiles).

When I open a cmd box on my Windows 7 64-bit, I can issue the "set" command to get

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

This should be similar under Windows 8.




回答4:


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

This is looking for a 64bit version of the java JDK.

C:\Program Files (x86) is the x86 not 64bit.

Click the link below and make sure to download the x64 version.

Java SE Development Kit 7 Downloads

Then the folder path should be

C:\Program Files\Java\jre7



回答5:


Try runing Android Studio as administrator after setting the JAVA_HOME variable! It worked for me...




回答6:


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.




回答7:


the solution is simple,

I think your java path contains /bin

C:\Program Files\Java\jdk1.8.0_181

just path to the folder of JDK

like C:\Program Files\Java\jdk1.8.0_181

don't forget to restart your IDE or Code Editor



来源:https://stackoverflow.com/questions/20204602/problems-setting-the-java-home-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!