Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio, define a JAVA_HOME variable

I saw a video on Youtube for enhancing the performance of Android Studio. I did and now I can't launch my Android Studio. Now it gives an error saying that "If you already have a 64-bit JDK installed, define a JAVA_HOME variable in Computer > System Properties > System Settings Environment Variables. Failed to create JVM. JVM Path C:\Program Files\Android\Android Studio\jre\jre"

enter image description here

I searched the whole internet and tried every solution mentioned but I still get the "define JAVA_HOME variable" error. I tried both completely uninstalling the Android Studio with all files and related folders manually deleted but still get this error and Android Studio just won't simply run. I have exams in a few days and I have a lot to practice.

Edit:

enter image description here

I just removed the JAVA_HOME. I have both the JDK and JVM installed. I am just uninstalling and installing Android Studio at the moment.

Edit 2:

enter image description here

like image 288
Isaac Avatar asked Jan 09 '21 15:01

Isaac


People also ask

Can I set JAVA_HOME in user variable?

To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

What is the JAVA_HOME variable?

JAVA_HOME is an operating system (OS) environment variable which can optionally be set after either the Java Development Kit (JDK) or the Java Runtime Environment (JRE) is installed. The JAVA_HOME environment variable points to the file system location where the JDK or JRE was installed.

What is difference between JAVA_HOME and path?

PATH values: notice how the directory we set for JAVA_HOME is the JDK installation root whereas for PATH we add the bin directory within the JDK installation. Take care to set these up correctly otherwise you'll have problems later on.


1 Answers

Okay, so I found an answer after spending 5 hours fixing\setting Environment Variables (JAVA_HOME), uninstalling and reinstalling both the JDK and Android Studio.

The answer was simple. For any version of Android Studio that is >version 4.0, you need to remove the "studio.exe.vmoptions" or "studio64.exe.vmoptions" (depending on your system) from the directory "C:\Users{Your Username}\AppData\Roaming\Google{Android Studio Version}".

like image 151
Isaac Avatar answered Sep 19 '22 21:09

Isaac