Kalaiselvi
Kalaiselvi

Reputation: 1

About JVM creation

When does the instance of JVM created? If 2 JVMs running parallel in the same system,whether the program that running in one Jvm can access the program that is running in another one? I heard that this is true. Is that so?

Upvotes: 0

Views: 1283

Answers (3)

Andreas Dolk
Andreas Dolk

Reputation: 114837

No, it is not true. You'll have two strictly separated virtual machines and objects living in one VM can't send messages to objects living in the other one or share data.

The virtual machine is started/created/... when you call java.

Upvotes: 1

rodion
rodion

Reputation: 15029

One instance of JVM is created per process. That is, one independent instance is created every time you run java.exe. Such JVMs are completely separate of each other, therefore you can even run different versions of JVM on the same machine.

There is no transparent way for JVMs to communicate with each other. However, java comes bundled with RMI, an inter-process communication tool, which allows almost transparent cross-JVM communication. But of course it involves specifying other JVM's hostname and port of communication, so you need to a bit of work to get it to work correctly.

Upvotes: 0

tgdavies
tgdavies

Reputation: 11484

Two JVMs can only talk to each other using inter-process communication methods, just as two non-JVM processes would do.

i.e. they need to use a shared database, a message queue, sockets -- or even plain files to share data.

Upvotes: 2

Related Questions