File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Need Solid Explanation of  Java.exe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need Solid Explanation of  Java.exe" Watch "Need Solid Explanation of  Java.exe" New topic
Author

Need Solid Explanation of Java.exe

Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
We everyone know Java is architecture neutral .... But, Eventually java.exe needs to invoke native OS to do the job....
I have read several articles regrading this.

Some of them said , jvm.exe has to invoke java.dll then... after that real jvm instance will be started..... I will be very pleased if somebody can explain this in detail.



Thinker
Nuwan Arambage
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

java.exe is the Windows version of the Java Virtual Machine. A Java program consists of .class files which contain Java byte codes. As you pointed out, these aren't meaningful to the underlying machine so the JVM reads Java byte codes and translates them to machine code specific to the machine you're running on. That's all there is to it. Your friends who talked about jvm.exe and java.dll are needlessly confusing the issue.
Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
Greg Charles wrote:java.exe is the Windows version of the Java Virtual Machine. A Java program consists of .class files which contain Java byte codes. As you pointed out, these aren't meaningful to the underlying machine so the JVM reads Java byte codes and translates them to machine code specific to the machine you're running on. That's all there is to it. Your friends who talked about jvm.exe and java.dll are needlessly confusing the issue.


It can't be miracle....... how jvm interpret bytecode with help of native OS... I wonder how jvm invoke OS to interpret bytecode.............
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18650
    
    8

Nuwan Arambage wrote:It can't be miracle....... how jvm interpret bytecode with help of native OS... I wonder how jvm invoke OS to interpret bytecode.............


No, it's not a miracle. It's just programming. In particular java.exe is a Windows program which interprets byte-code. When it comes across something which needs to work with Windows -- for example classes like java.io.File -- it uses native methods which are written for Windows to do that work.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Doing a trivial web search for "virtual machines" should be enough to start you understanding what a virtual machine is, and some of the ways they can be implemented. A very simple virtual machine can be written in tens of lines of code--it wouldn't do much, but it's far from magic. For more references, including links to a *lot* of virtual machines, see the Wikipedia virtual machine entry.

The JVM does not "invoke" the OS to interpret bytecode. The JVM interprets the bytecode and implements the underlying virtual machine that is the bytecode's environment. As Paul said, the only time the OS gets involved is at the system level: files, access to timers, and so on.

(One irony is that back when I started computing, virtual machines existed all over: p-code was a virtual machine. There was a virtual machine inside Apple II BASIC. Then they kind of went away, then they came back.)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Greg Charles wrote:[...] Java byte codes [...]aren't meaningful to the underlying machine[...]

That's *almost* always true, but hardware JVM implementations have existed.
Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
David Newton wrote:Doing a trivial web search for "virtual machines" should be enough to start you understanding what a virtual machine is, and some of the ways they can be implemented. A very simple virtual machine can be written in tens of lines of code--it wouldn't do much, but it's far from magic. For more references, including links to a *lot* of virtual machines, see the Wikipedia virtual machine entry.

The JVM does not "invoke" the OS to interpret bytecode. The JVM interprets the bytecode and implements the underlying virtual machine that is the bytecode's environment. As Paul said, the only time the OS gets involved is at the system level: files, access to timers, and so on.

(One irony is that back when I started computing, virtual machines existed all over: p-code was a virtual machine. There was a virtual machine inside Apple II BASIC. Then they kind of went away, then they came back.)


So thanks for your help........ It is vast area than I was thinking.......... Anyway..... going to strive for it..........
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3646
    
  15
Paul Clapham wrote: In particular java.exe is a Windows program which interprets byte-code.


Actually java.exe (and the equivalent executables on other platforms) are just launcher programs. The JVM itself is in a native library (java.dll or jvm.dll on windows depending on the Java version) which is loaded by the launcher program.
It is possible to replace the launcher program with your own program that simply calls the appropriate entry point in the native library. I believe web servers such as Tomcat do this.
See this for further details of how these custom launchers work.
Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
Joanne Neal wrote:
Paul Clapham wrote: In particular java.exe is a Windows program which interprets byte-code.


Actually java.exe (and the equivalent executables on other platforms) are just launcher programs. The JVM itself is in a native library (java.dll or jvm.dll on windows depending on the Java version) which is loaded by the launcher program.
It is possible to replace the launcher program with your own program that simply calls the appropriate entry point in the native library. I believe web servers such as Tomcat do this.
See this for further details of how these custom launchers work.



I think you have demystify FUD.... :
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39393
    
  28
Nuwan Arambage wrote: . . . I think you have demystify FUD. . . .
Details of FUD here.
Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
Campbell Ritchie wrote:
Nuwan Arambage wrote: . . . I think you have demystify FUD. . . .
Details of FUD here.



I mean , I have got the answer from you .... I mean Fear , Uncertainty & Doubt ....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Joanne Neal wrote:See this for further details of how these custom launchers work.

Hey, that was interesting--thanks for the link. None of the JNI stuff I did was this direction, it was always the other way.
Nuwan Arambage
Ranch Hand

Joined: May 05, 2010
Posts: 76
Finally I should come to a clear idea....

Java.exe is just a launcher programme and then it calls JNI for invoking native jvm.dll or java.dll(it depends on the OS
you are using.). finally JVM run as a process in a native OS...

Is this correct......... If soemthing mising .... Be kind enough to put a comment..... & clear the ground for greenhorns..
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The ...\jre\bin\java.exe is simply a Microsoft Windows implementation of the JVM. If you look in the \jre\bin folder of a Windows JDK, you will find many .exe and .dll files. All of these are part of the implementation.

With a different operating system, e.g. AIX, there is a different implementation of the JVM.

Think of the Java virtual machine (JVM) as a document with specifications and rules, and think of an OS-dependent Java run-time environment (JRE) as the implementation of the JVM specifications and rules.

There is only one JVM specification in the world. There are many JREs which implement the specification.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Bennett wrote:The ...\jre\bin\java.exe is simply a Microsoft Windows implementation of the JVM.

Doesn't sound like it from the explanation given above.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3646
    
  15
Frank Bennett wrote:The ...\jre\bin\java.exe is simply a Microsoft Windows implementation of the JVM. If you look in the \jre\bin folder of a Windows JDK, you will find many .exe and .dll files. All of these are part of the implementation.


No. The stuff in jre/bin (and jre/lib) are parts of the JRE implementation of which the JVM is part. On a Sun JRE the JVM itself is in the client or server subdirectory of the bin directory.
The diagram here gives a nice overview of what exactly the JRE and JVM are.

See also 18 in the JavaBeginnersFaq which is where I borrowed the link to that diagram from.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The JVM is only a specification. It is a bunch of English words. It has sections and ammendments and clauses...that is all.

A JRE is an implementation of the JVM specification. There are many implementations.

Individuals often confuse JVM and JRE, and refer to a particular operating-system-specific JRE as a JVM.

A JRE is the actual computing software. The JVM is the specification of what the software does. The JVM is just a bunch of words. Confusion most likely stems from the terms "virtual" and "machine." The official name is The Java Virtual Machine Specification.

P.S. The graphic in the link above doesn't illustrate this clearly however.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The point was that java.exe is not the JRE JVM, the DLL/library is.

And a JRE is includes an implementation of the JVM--so it's *a* JVM.

Edited to reduce the confusion introduced a bit later in the thread and to coincide with the link Joanne provided.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The point was that a JRE is many files not only one. To consider the java.exe a part of a JRE is logical thinking in my opinion. Either way, it is a trivial micro concept to waste energy on.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Well, that's ironic then. But you didn't say it was part of a JRE, you said it was the Windows implementation of the JVM, which doesn't really seem to be the case.

Someone was asking a specific question about implementation details; micro-optimization or not we should strive for accuracy, no?
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Dave, you should read the post again. The "Windows implementation of the JVM" is a JRE.

The phrase "Windows implementation of the JVM" and the acronym "JRE" is synonymous (alike in meaning or significance).

Reading comprehension is a good skill to have ....lol Instead of disecting individual sentences and interpreting what they mean like they were lines of code, you might understand better if you tried to grasp the entire messaage and the context. The rest of the post explains all of this. You are only reading a single sentence, instead of the entire message.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You should mind your tone, and re-read the link Joanne posted. Here's the chart that is giving you problems:



The JVM is a JVM (the single row at the bottom). The JRE is a JVM plus a whole bunch of other stuff (the eight rows above it). Not synonymous, nor a particularly difficult difference to understand.

"Dissecting individual sentences" is how meaning arises. There is no context in which:
The phrase "Windows implementation of the JVM" and the acronym "JRE" is synonymous (alike in meaning or significance).
is correct. When we're trying to answer a very specific question asked by someone trying to understand the difference, it's better to be correct and obsessive, than completely wrong, and rude.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Frank Bennett wrote:To consider the java.exe a part of a JRE is logical thinking in my opinion.

We don't disagree on that part, by the way--only that JRE != JVM, and java.exe != JVM. The OP is asking for a *solid* explanation, which Joanne provided.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
By the way, I wasn't being rude. Couldn't you tell by the tone of my voice and my facial expression when I posted the message last night. lol
Quite the contrary...
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I must have misinterpreted the comment about my lack of reading comprehension skills.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19718
    
  20

Let's keep that discussion out of this, shall we? Use private messages, or possibly the Ranch Office forum, if either of you wishes to continue.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Solid Explanation of Java.exe