10

The JDK comes with the java.exe (for windows) program. You can use it to start programs from the command line.

Wikipedia says it's the 'class loader', and 'an interpreter for class files'.

Is this the actual full blown JVM? Is it a 'smaller, lightweight' JVM? Is it something else?

Aviv Cohn
  • 15,543
  • 25
  • 68
  • 131
  • 3
    See http://stackoverflow.com/questions/26020872/totally-confused-with-java-exe/26025656#26025656 – apangin Sep 26 '14 at 07:53
  • This question does not feel like a duplicate of said closed-for question because it is about the semantics of the Wikipedia article and wording; the other question is asking about how the JRE stack is implemented wrt. executables/classes/assets. That is *something* must still "load and interpret", it doesn't matter if it is in an executable itself, library code in a DLL loaded from the executable, or a service hosted on some remote server, etc. – user2864740 Sep 26 '14 at 19:15

3 Answers3

8

A JVM does both of those tasks, by definition and requirement.

In a mature implementation, including HotSpot, a JVM does much more including Just-In-Time compilation (as deemed useful) - but it must still load and interpret the class files and Java bytecode. Knowing this should alleviate the confusion about the article using "interpreter"; it explains the conceptual task and should not be taken to mean smaller or lightweight.

That is, java/javaw launches the "full JVM" in a standard Oracle/OpenJDK environment.

Community
  • 1
  • 1
user2864740
  • 60,010
  • 15
  • 145
  • 220
  • 1
    What file contains machine code that makes up the VM itself? – nanofarad Sep 26 '14 at 10:46
  • There is not just one file, there will be multiple and which ones exist are system and version dependent. Check out the bin directory of the runtime to already find most of them. The main shared library will be 'jvm.xxx', for example jvm.dll in the Windows version. – Gimby Sep 26 '14 at 11:03
  • @hexafraction `jvm.dll` on Windows or `libjvm.so` on Linux – apangin Sep 26 '14 at 12:06
  • @hexafraction Information along those lines is provided in the linked answer for "launches"; this is an implementation detail (of calling-out to a library) and such a thin-wrapper executable approach is found in many larger applications. Besides project management, it is beneficial to use a library for systems like the JVM because it also allows the same library/compile-code to be used by *both* java and javaw executables, and in Applets or other processes hosting the JVM. – user2864740 Sep 26 '14 at 18:53
8

java.exe is just a VM launcher. It creates a VM and runs it. JVM located in the jvm.dll (or libjvm.so on Linux).

I work with OpenJDK (NOT in OpenJDK team) and can tell you more details, if you are interested.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
Kastaneda
  • 739
  • 1
  • 8
  • 15
  • 6
    We are interested. – topher Sep 26 '14 at 11:29
  • @topher, ok, i'll create a post about it, and then paste link to post here. I'm not sure - can i create post (not question) on SO? P.S. i'm just learning English and my answers may contains few mistakes) – Kastaneda Sep 26 '14 at 12:16
  • 1
    It's ok. We are here to learn. Just edit your answer to include any information you think is relevant. Any language issues in your post will be corrected by the community. – topher Sep 26 '14 at 13:41
0

java.exe feeds your class files to JVM so it can perform JIT and interpret the code. java.exe by itself is not a VM, no. It launches one and provides all necessary data for it.

In order to compile your code, you should use javac.exe.

Suppose you have Test.java class code, now you need to compile it:

javac Test.java

Compiler will output Test.class compiled file, which contains JVM bytecode.

Now, in order to execute it on JVM, you run

java Test

which finds entry point in available .class files and feeds JVM with it.

GuardianX
  • 515
  • 11
  • 29
  • Most JVM implementations perform JIT (Just In-Time) compilation of the bytecode to native code, so it is not just an interpreter. – Mark Rotteveel Sep 26 '14 at 07:42
  • JIT is VM's prerogative, java.exe is not JVM, strictly speaking. It just launches it and feeds it with the code. – GuardianX Sep 26 '14 at 07:45
  • By that logic, `java.exe` doesn't even feed the JVM code, that is done by the `ClassLoader` which is part of the JVM. – Mark Rotteveel Sep 26 '14 at 07:53
  • @MarkRotteveel that is what my answer about. ClassLoader is a part of JVM, but it gets all of the necessary data to load the code from java.exe. Which implies that "java.exe feeds the code to JVM". – GuardianX Sep 26 '14 at 09:41