• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

An idiots questions about the JVM

 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Wim Vanni
Ranch Hand
Posts: 96
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For those who are interested in how the JVM works, as Wolfgang appears to be, this is probably a good place to start.
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22086
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Wolfgang Tintemann
Ranch Hand
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 22086
88
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 65
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joanne, javap is exactly what I was looking for. Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic