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

2

8

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.

Homophone answered 14/5, 2015 at 15:26 Comment(6)
Possible duplicate of #24899184Yi
What other Java application doesn't work? Note that JAVA_HOME isn't a Java setting. It's a setting used by other applications that need to know where Java is. Different applications might use JAVA_HOME differently.Mcbroom
"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. See #5102522. "If it is reconfigured to sdk path then my other java application don't work" -- then there is a problem with those other applications.Almonry
@Almonry As suggested I have changed the values, AndroidStudio works fine but when I enter javac in command prompt it gives me error as Not Recoginzed.Homophone
if it is not recognized then you need to add the bin folder to the path, then close the CMD then open another one (the javahome should not be the bin, though)Niemeyer
Yup I have done that as can be seen in the image above...but still I get this error msg...ThanksHomophone
A
12

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.

Almonry answered 14/5, 2015 at 20:45 Comment(0)
C
1

the java_home should not include bin but you should add /bin when you add java_home to path like this: export JAVA_HOME=.../jdk-xx/ export PATH=$JAVA_HOME/bin:PATH

Checkoff answered 14/10, 2020 at 2:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.