Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why should JAVA_HOME environment variable value point to SDK directory instead of bin?

Generally inorder to run Java applications we set JAVA_HOME value to java sdk directory/bin

But when this set and I try opening Android Studio it gives be an error saying JVM is not configured in your machine and doesn't open up.

If we reconfigure the JAVA_HOME to only java sdk directory path it works fine. But I wonder why this is happening??

If it is reconfigured to sdk path then my other java application don't work. Please let me know your thoughts on this.

Update: Please find image below when JAVA_HOME var is conifgured to right JDK dir, javac doesn't execute in command prompt

enter image description here

Thanks, Nav.

like image 956
Dex Avatar asked Feb 10 '23 03:02

Dex


1 Answers

Generally inorder to run Java applications we set JAVA_HOME value to java sdk directory/bin

No. Traditionally, JAVA_HOME is set to the JRE or SDK main directory. The bin/ subdirectory might be in your PATH, though.

I have changed the values, AndroidStudio works fine but when I enter javac in command prompt it gives me error as Not Recoginzed

That is because your PATH is wrong. Your PATH needs to point to the bin/ directory within your Java SDK. My guess is that your PATH is referencing JAVA_HOME, but assuming (incorrectly) that JAVA_HOME points to that bin/ directory. Just change your PATH to ensure that it picks up the bin/ directory.

like image 142
CommonsWare Avatar answered Feb 13 '23 05:02

CommonsWare