1

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.

ferpel
  • 206
  • 3
  • 12
  • See [which one should JAVA_HOME to point, JDK or JRE](http://stackoverflow.com/questions/17601827/which-one-should-java-home-to-point-jdk-or-jre), `JAVA_HOME` helps the system find the right binary in `bin`folders. – Neo X Feb 23 '17 at 03:24
  • `jre/bin` (Java Runtime Environment) is usually used when you're running software that uses java, but you don't want to actually compile java source code. `idk/bin` is used when you want to develop software using Java (Java Development Kit). – David Choweller Feb 23 '17 at 03:24
  • So the route for JAVA_HOME in the /etc/environment where should be pointing at? JDK? – ferpel Feb 23 '17 at 03:25
  • Thank you @Neo X I'll read it. Thanks David for your answer too – ferpel Feb 23 '17 at 03:27

1 Answers1

2

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216