JDK java executable vs JRE executable

I installed Oracle JDK to / usr / jdk / jdk 1.8.0_25 and set that directory to JAVA_HOME. JAVA_HOME / bin contains the java executable and JAVA_HOME / jre / bin contains another java executable. Following tutorial I asked to add JAVA_HOME / bin and JAVA_HOME / jre / bin to PATH, but which is the correct executable to use, and which will be used if I call java from the command line?

+3


source to share


3 answers


Here is a simplified overview of the differences between JDK and JRE

JRE stands for J ava R untime E nvironment: it only contains binaries to run a java program

JDK stands for J ava D evelopment K : it contains binaries to run java program + binaries to compile Java source code (and create java program).

JDK always contains JRE inside (under directory <JDK_HOME>/jre

)



The main difference between JRE and JDK is the javac program. (javac stands for java c ompiler) (you will also find some other programs under <JDK_HOME>/bin

that are missing in <JDK_HOME>/jre/bin

: all of them can be useful for java development, but in most cases it is useless to run a java program.

All programs that are in both locations (i.e. <JDK_HOME>/bin

and <JDK_HOME>/jre/bin

) are the same, so no distinction needs to be made.

To answer your question exactly: the java instance that will be started when the command line starts with java is the first java instance found in your system PATH ... just like any other program.

+2


source


Whatever comes before the path for java is JAVA_HOME / bin or JAVA_HOME / jre / bin.



If you look at the folder structure where jdk / jre is installed, you can see that there is quite a bunch of binaries in the jdk / bin folder like java, javac, javap, etc. The JRE will include java, but not javac, javap, etc. I am assuming it is linux and you downloaded the compressed archive and extracted it.

0


source


If you're really interested, you can write this on the command line:

where java

      

This will give the exact location of the executable. On my PC it gives me

C:\ProgramData\Oracle\Java\javapath\java.exe

      

which is a soft link for the default system runtime java.exe

(in my case it is C:\Program files\Java\jre 1.8.0_25\bin\java.exe

)

0


source







All Articles