How Java Virtual Machine Works

Published: 30 June 2014
on channel: Techy Help
9,831
like

Can you tell me how Java Virtual Machine works?

Java Virtual Machine or JVM has the motto write once, run everywhere.

I know the motto, but I do not understand the how.

Because Java Virtual Machine compiles code at real time, AKA just in time compilation, you see slightly slower execution. But since you run JVM directly on your computer, this ensures that Java runs on every type of device.

And generates just as many errors, too.

JVM creates a runtime instance every time you start a Java application. It is supposed to kill the instance when the application completes.

It manages to crash often enough.

Java Virtual Machines terminate the JVM runtime when all non-daemon threads are running. If the daemon threads are running, it still goes on, but JVM can kill an application through the security manager using the exit method.

When something is found wrong by security, head to the exits. But how does JVM work?

Java source code is saved as .java source files, but it is translated into Java bytecode. When you run Java, the Java Virtual Machine converts the bytecode into machine instructions.

It has to be good, because a lot of languages now use the JVM. But won't it crash if I have more than one running?

Each Java application uses its own Java Virtual Machine.

So JVM is virtual, and I can have more than one JVM running?

That's right.

So I could have lots of different types of applications using JVM, and it won't error out.

No more than usual. There are several versions of JVM, too, though the most common version of JVM was written by Oracle, its creator.

So JVM is an execution method for any language that is written to use it.

And JVM is compatible with almost any device because it compiles code in real time using a native method interface and native libraries.

It's a code translator.

That's a fair way of looking at it.


Watch video How Java Virtual Machine Works online without registration, duration hours minute second in high quality. This video was added by user Techy Help 30 June 2014, don't forget to share it with your friends and acquaintances, it has been viewed on our site 9,831 once and liked it like people.