Mannan
Mannan

Reputation: 19

why we need the jvm instances to run our java program

I'm new to Java. I understand that an instance of the JVM is created whenever a Java program is started. But I wonder why a JVM instance must be created.

In java an instance is usually created to pin point where the class exist likewise. Is a JVM instance also pointing any classes?

I really don't know the purpose of the JVM instance apart from that it is used to run a program.

Could anyone explain me the reason?

Upvotes: 1

Views: 266

Answers (3)

Nakul91
Nakul91

Reputation: 1245

In Java, the process of writing to executing a program is very similar to C/C++, but with one important difference that allows us to write Java programs that are machine independent.

Using an interpreter, all Java programs are compiled to an intermediate level called byte code. We can run the compiled byte code on any computer with the Java runtime environment installed on it.

The runtime environment consists of a virtual machine and its supporting code.

May be you can take a look at this thread to solve your doubts:

How is Java platform-independent when it needs a JVM to run?

Upvotes: 4

Bhargav Kumar R
Bhargav Kumar R

Reputation: 2200

JVM converts your byte code to machine dependent instructions in order for your hardware to understand and execute those instructions. JVM comes with JDK(Java Development Kit).

Yes, to answer your question JVM provides a platform for running your code. Apart from this, it does quite other stuff like memory management, garbage collection, internal thread management and a lot.

Have a look at this. You will understand.

Upvotes: 0

Nishant Chawla
Nishant Chawla

Reputation: 11

JVM stand for JAVA virtual Machine it is the machine dependent program that will actually read your compiled and convert that code into the machine dependent instructions and thus execute that particular program. May be this will clarify your question

Upvotes: 1

Related Questions