2

The JDK is the superset of JRE. JDK has the necessary tools like javac java.exe debugger etc + JRE. But JRE has a particular implementation of JVM.

My assumption is java.exe or the java application launcher is the interpreter (please correct me if I'm wrong). Also, JVM does the interpretation as well.

Finally is the interpreter part of JVM or part of JDK tools? Please explain.

  • 1
    My question is not the difference b/w JDK , JRE etc. the doubt that I have is if at all I have just JRE in my system, how can the JVM use the interpreter which is actually a part of JDK tools. – karthik4621 Sep 24 '14 at 18:31
  • 1
    @karthik4621 The JRE *is* the JVM (plus a bit more). It *is* the bytecode interpreter. – Dave Newton Sep 24 '14 at 19:51

3 Answers3

21

java.exe is neither a JVM nor an interpreter. It is a launcher - a small program typically written in C which does the following:

  1. Locates an installed JRE
  2. Loads JVM dynamic library (jvm.dll)
  3. Creates a new Java Virtual Machine using the Invocation API
  4. Finds the main class and calls the main() method using JNI

JRE roughly consists of

  1. JVM - jvm.dll
  2. Class Library - rt.jar
  3. Native libraries - the layer between the class library and the OS platform, e.g. java.dll, net.dll, nio.dll, awt.dll etc.
  4. Resources - fonts, properties, strings etc.

Now, the Bytecode Interpreter, the Bytecode Verifier, the Class Loader, the JIT compiler, the Garbage Collector and many other cool stuff - are all parts of the Java Virtual Machine.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Thanks. Could you give a Linux version of explanation of ELF file `java`? Is it basically the same as the Windows version, by replacing `.dll` with `.so` in your reply? – Tim Apr 14 '19 at 11:13
  • Do all the threads (implicitly created when running `java` command to run a compiled Java program) execute a Java Virtual Machine? Or just some of the threads? https://stackoverflow.com/questions/55666827/what-are-threads-i-e-lightweight-processes-named-java-created-for/55669949#55669949 – Tim Apr 14 '19 at 11:18
  • @Tim Yes, the same is true on Linux. – apangin Apr 14 '19 at 11:48
  • All threads created by JVM are running Java Virtual Machine code. Sometimes it is a native code (e.g. for compiler threads and GC threads), and sometimes it is Java code. – apangin Apr 14 '19 at 11:49
  • @apangin is java.exe a part of the Development tools of JDK or a part of the Supporting files (deployment technology files, user interface toolkit files and library files) of the JRE? – user12208242 May 05 '20 at 17:05
  • @user12208242 If java.exe is needed to launch Java programs, what do you think it belongs to? See [this question](https://stackoverflow.com/questions/1906445/what-is-the-difference-between-jdk-and-jre) – apangin May 05 '20 at 19:16
-2

@karthik4621 java.exe/javaw application is part of JRE look into the JRE installation directory to find bin folder, to find the executable's and the java.exe you find bundled along with JDK is also same :) for more insight on the issue i suggest you read through oracle docs as well as the quick brush up of contents of the JDK/JRE install locations –

snoopy
  • 44
  • 10
  • try using a java.exe available in the JRE's bin directory to interpret a byte code (any per-compiled .class file to know the difference and be sure to remove path environment variable pointing to java.exe at the JDK install location ) – snoopy Sep 24 '14 at 19:55
-3

you are right java.exe is the interpreter for JVM (java virtual machine) and JVM is where your code gets executed by communicating with the underlying OS

snoopy
  • 44
  • 10
  • What is it interpreting? – Sotirios Delimanolis Sep 24 '14 at 15:42
  • But my question is if at all I have just JRE in my system, how can the JVM use the interpreter which is actually a part of JDK tools. – karthik4621 Sep 24 '14 at 18:16
  • @karthik4621 java.exe/javaw application is part of JRE look into the JRE installation directory to find bin folder, to find the executable's and the java.exe you find bundled along with JDK is also same :) for more insight on the issue i suggest you read through oracle docs as well as the quick brush up of contents of the JDK/JRE install locations – snoopy Sep 24 '14 at 19:45