JAVA_HOME is set to an invalid directory. Set the JAVA_HOME variable in your environment to match the location of your Java installation

Viewed 20

I started with react Native and could not run the emulator when executing the npx react-native run-android command. Also, my disk space was full, so I uninstalled many programs, one of which happened to be Java. I uninstalled it thinking it to be Eclipse. This is the error it shows now whenever I run the command in Android Studio or VSCode:

JAVA_HOME is set to an invalid directory: D:\Program Files\Java\jdk-11.0.16.1\bin Please set the JAVA_HOME variable in your environment to match the location of your Java installation.

error Failed to install the app. Make sure you have the Android development environment set up

I've been stuck with this for the whole day. I reinstalled Java. I changed the JAVA_HOME in the environment variables to point to where java has been installed in the D drive. I went to the old path in C:/users/user/Local/AppData/Programs/Eclipse/ but cannot close it as it says the system is still using it. I can't figure out how to fix this. Would love the help. Thanks.

Java has been correctly installed on my device. The command prompt shows the following:

java -version
java version "11.0.16.1" 2022-08-18 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.16.1+1-LTS-1)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.16.1+1-LTS-1, mixed mode)

javac -version
javac 11.0.16.1

My JAVA_HOME path is:

D:\Program Files\Java\jdk-11.0.16.1\bin

0 Answers
Related