[java] Android Studio error: "Environment variable does not point to a valid JVM installation"

In my case, the problem was that a line feed had gotten into the setting of the JAVA_HOME variable. I'm not sure how, but I was mucking with it earlier because I had had an issue with an unrelated ant build that was using JAVA_HOME, and I copied the path in.

I noticed the problem partially when I did a "set" command from the command line, and it showed "JAVA_HOME" on one line and the path on the next line, and a blank line after it.

But what really helped was running the gradle command. It gave the same error message. That gave me confidence that the problem really was the JAVA_HOME variable, and not the Android Studio install.

To solve the problem, I deleted the JAVA_HOME variable first. Then, when setting up the command to set the variable, I keyed in the path manually in Textpad, to make sure there were no linefeeds or carriage returns.

Then I ran the command:

setx JAVA_HOME "C:\Program Files\Java\jdk1.7.0_71"

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to jvm

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 How can I get a random number in Kotlin? Kotlin unresolved reference in IntelliJ Is JVM ARGS '-Xms1024m -Xmx2048m' still useful in Java 8? Android Gradle Could not reserve enough space for object heap Android java.exe finished with non-zero exit value 1 Android Studio Gradle project "Unable to start the daemon process /initialization of VM" Android Studio - No JVM Installation found Android Studio error: "Environment variable does not point to a valid JVM installation" Installing Android Studio, does not point to a valid JVM installation error

Examples related to java-home

Set ANDROID_HOME environment variable in mac Error: JAVA_HOME is not defined correctly executing maven How to set JAVA_HOME in Linux for all users Android Studio error: "Environment variable does not point to a valid JVM installation" Installing Android Studio, does not point to a valid JVM installation error How can I change Mac OS's default Java VM returned from /usr/libexec/java_home How to set JAVA_HOME path on Ubuntu? Where is the Java SDK folder in my computer? Ubuntu 12.04 How to set JAVA_HOME in Mac permanently? How to set CATALINA_HOME variable in windows 7?