aspose file tools*
The moose likes Java in General and the fly likes An idiots questions about the JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "An idiots questions about the JVM" Watch "An idiots questions about the JVM" New topic
Author

An idiots questions about the JVM

Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Let me make a down-to-earth assumption that I work on
a Windows 7 system und have the JRE and JDK installed.

Here some desperate questions about the JVM :

1. Is the JVM a program written in C ?
( because I see a jvm.dll file under bin/client )
2. Is the JVM a Windows Application program ?
3. Are my Java GUI commands translated into
Microsoft Windows API calls or does the JVM
somehow build the GUI with its own bytecode (?)
commands ?
4. E. g., how are threads, timers or file/device IO
realized by the JVM : call of Microsoft API functions ?
How are the OS commands represented in the bytecode.
( until now I only found simple examples which dealt
with the stack programming )

Please excuse my confusion but I dont find any information
until now.


Time isn't Money, Money is Time.
The man who works looses his time ( spanish proverb )
Wim Vanni
Ranch Hand

Joined: Apr 06, 2011
Posts: 96

Never start by saying your question is an idiots question. Idiots, in their own weird conception of the world, ask the most logic questions you can encounter.

Next, I don't know why you make that assumption in the beginning of your post. Whether you have or have not installed the JRE and JDK is information that does not help in answering your questions.

Finally: I find it very strange that you are desperate and confused about those questions. Any article or book that is an introduction to Java covers the JVM mechanism that is so fundamental to Java. And aside a global understanding of what it does I never questioned the details of how a 'Hello World' main method outputs text to the console. Or how Swing objects show up as GUI-elements in my Windows or my neighbours Linux machine.

Maybe I'm just one of those guys who doesn't care how a car engine works as long as the car gets me from A to B.

Cheers,
Wim
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3153
    
  10
For those who are interested in how the JVM works, as Wolfgang appears to be, this is probably a good place to start.


Joanne
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Thanks for this link.
But what I am interested in is more the hardware- and operating system dependent binary format.

What I found until now is that Threads are ( if I understand right ) handled in a operating system
independent way.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39

Wolfgang Tintemann wrote:1. Is the JVM a program written in C ?
( because I see a jvm.dll file under bin/client )


Yes. C, C++, and a little bit of assembly.

Wolfgang Tintemann wrote:2. Is the JVM a Windows Application program ?


On Windows, yes.

Wolfgang Tintemann wrote:3. Are my Java GUI commands translated into
Microsoft Windows API calls or does the JVM
somehow build the GUI with its own bytecode (?)
commands ?


Both. There are some components which map to windowing components in the native windowing system. There are other components that are build on topic of those components, and do all the drawing and handling in pure Java.

Wolfgang Tintemann wrote:4. E. g., how are threads, timers or file/device IO
realized by the JVM : call of Microsoft API functions ?
How are the OS commands represented in the bytecode.
( until now I only found simple examples which dealt
with the stack programming )


The threads libraries (for all modern JVMs) do call out to the native threading system. The file I/O apis do all eventually call out to the OS calls to do the I/O.

There are no byte code that represent OS commands. The byte code are for method calls -- whch call methods in the core library, which makes other method calls, which eventually makes a JNI method call to call a C/C++ function, which in turn call the OS system calls.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Great information, Henry.

Do I understand right that in my case "native" means the call of
a C-function of the Microsoft API ?

Is there an example available how such a "native" invocation
looks like in the bytecode ? Can I analyze a .class file simply
with an editor ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39

Wolfgang Tintemann wrote:
Do I understand right that in my case "native" means the call of
a C-function of the Microsoft API ?


Not exactly. Using JNI (java native interface) -- java will call out to C/C++ code in a DLL (for windows). This C/C++ code must following a very exact format, which of course, is not the Microsoft API However, this C/C++ code can, in turn, call out to any code that is accessible -- which of course, can be the Microsoft API.

Wolfgang Tintemann wrote:
Is there an example available how such a "native" invocation
looks like in the bytecode ? Can I analyze a .class file simply
with an editor ?


Google for "java native interface".

Henry
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Thank you very much, Henry.

Though I dont understand not all of the notions I think my questions are
fully answered.

Is there a software tool which shows the contents of a .class file in the
readable way I found in books or saw in videos ?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Wolfgang Tintemann wrote:Is there a software tool which shows the contents of a .class file in the readable way I found in books or saw in videos ?

Search for java decompilers
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3153
    
  10
John Jai wrote:
Wolfgang Tintemann wrote:Is there a software tool which shows the contents of a .class file in the readable way I found in books or saw in videos ?

Search for java decompilers

I think Wolfgang was referring to seeing the byte code in a readable format. If so, then take a look at the javap tool that comes with the JDK.
Wolfgang Tintemann
Ranch Hand

Joined: Sep 11, 2010
Posts: 65

Joanne, javap is exactly what I was looking for. Thanks.
 
jQuery in Action, 2nd edition
 
subject: An idiots questions about the JVM
 
Similar Threads
Basic Java Concepts Clarification
Multithreading & java.lang
Launching a Java program on Microsoft Windows...
getting output from DOS into GUI
Java Basics