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.

Dex
  • 388
  • 5
  • 31
  • 1
    Possible duplicate of http://stackoverflow.com/questions/24898684/android-studio-no-jvm-installation-found – Harsh Dattani May 14 '15 at 15:28
  • 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. – Kevin Workman May 14 '15 at 15:33
  • "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 http://stackoverflow.com/questions/5102022/what-does-the-java-home-environment-variable-do. "If it is reconfigured to sdk path then my other java application don't work" -- then there is a problem with those other applications. – CommonsWare May 14 '15 at 15:36
  • @CommonsWare 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. – Dex May 14 '15 at 19:55
  • 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) – EpicPandaForce May 14 '15 at 19:58
  • Yup I have done that as can be seen in the image above...but still I get this error msg...Thanks – Dex May 14 '15 at 20:00

2 Answers2

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.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
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

Red
  • 19
  • 8