JAVA_HOME or PATH or BOTH?
Asked Answered
M

3

16

I was watching the Android development video and they asked us to install JDK and create JAVA_HOME environment variable. I already have MyEclipse installed and I previously had setup the PATH variable(giving it the directory of JDK), do I still need a JAVA_HOME variable ??? If yes then why ???

Magee answered 21/7, 2017 at 20:53 Comment(0)
S
5

If the application you are using is looking for a specific dataset in the JAVA_HOME environment variable and it isn't there, it is not going to be happy.

Other applications might look for the JDK path in the PATH environment variable, but just because you have it there doesn't mean it will work for other applications that need it in a separate variable.

Surgy answered 21/7, 2017 at 20:56 Comment(0)
M
17

Yes, you do need. PATH is usually used to lookup the executables so that you haven't to specify the whole path to execute. JAVA_HOME may be used by the scripts or IDEs to lookup libraries. You can specify JAVA_HOME and build path variable basing on it. E.g (depending on OS)

PATH=$PATH;$JAVA_HOME/bin
Mom answered 21/7, 2017 at 21:2 Comment(0)
P
11

Short answer, YES, you do need to set JAVA_HOME.

You can read here the difference between each one of them, but I'm pasting the explanations below as well:

  • JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.

  • CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. You do not normally need to set the CLASSPATH environment variable. Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands.

  • PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. The JDK installation instructions explain how to set PATH.

Polychromy answered 21/7, 2017 at 20:58 Comment(0)
S
5

If the application you are using is looking for a specific dataset in the JAVA_HOME environment variable and it isn't there, it is not going to be happy.

Other applications might look for the JDK path in the PATH environment variable, but just because you have it there doesn't mean it will work for other applications that need it in a separate variable.

Surgy answered 21/7, 2017 at 20:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.