Search code examples
javaenvironment-variablesjava-home

Whats the difference between the "java" file found in "jdk1.8.0_121/bin" and the one that's in "jdk1.8.0_121/jre/bin"?


I need to set the JAVA_HOME variable and I don't know which route I have to choose or if it's the same one or another.

I have two files named "java" one is into the "jdk/bin" folder and the another one is into "jdk/jre/bin" folder. What's the difference between them? Because searching over internet I see that there are people using one and another people using the other.


Solution

  • Whats the difference between the java file found in jdk1.8.0_121/bin and the one that's in jdk1.8.0_121/jre/bin?

    There is no difference in recent versions of Java; e.g. Java 8 or later. I have heard that there were small differences in older versions.

    So the route for JAVA_HOME in the /etc/environment where should be pointing at?

    The JAVA_HOME variable should point to the Java installation directory; i.e. jdk1.8.0_121 in your case.

    If you are configuring the PATH variable to explicitly contain a Java bin directory1, you would normally use jdk1.8.0_121/bin so that the development tools are on the command search path.

    Note that JAVA_HOME and PATH serve different purposes.

    • JAVA_HOME is used to tell 3rd-party tools where the Java installation is.
    • PATH is used by the shell to resolve command names.

    1 - The other way to do it on Linux is to use the alternatives tool.