How to communicate in Two JVM

In one client, from the main windows, open two sub-windows.

When open the two sub-windows, I want use different JVM. But I does not know how to communicate in two JVM each other.

[191 byte] By [weimenrena] at [2007-11-27 10:29:46]
# 1

Why would you want to run two VMs on a client?

Regardless you can either use sockets or files to communicate. You can wrap the socket communication in some other protocol such as RMI if you wish.

jschella at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2

Using sockets can be anyoing if a simplistic firewall is in place.

DikkeDouwea at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3

> Using sockets can be anyoing if a simplistic firewall

> is in place.

Using sockets can be annoying if there is no TCP/IP stack as well.

But of course that one means you can't use sockets at all, whereas the your suggestion just means that one has to understand the target platform.

jschella at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

Using JNI might help you out. Pls elaborate the question so that I can assist you in defining a method to do so.

SACHIN_SETH1203a at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5

> Using JNI might help you out.

How?

Certainly you can do sockets in C but then java already does that.

Via pipes? Or shared memory? Why are those better, particularly with JNI than sockets?

jschella at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6

I mean, While Java program running on default JVM, you can create another JVM using JNI and then call functions specifying the JVM on which that function has to be executed. I haven't tried creating JVM using JNI call, but there is a function to do so.

SACHIN_SETH1203a at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 7

> I mean, While Java program running on default JVM,

> you can create another JVM using JNI

Not with the Sun VM you can't.It will not create another VM.

> and then call

> functions specifying the JVM on which that function

> has to be executed. I haven't tried creating JVM

> using JNI call, but there is a function to do so.

And it will fail if a VM already exists in the same application.

jschella at 2007-7-28 17:59:24 > top of Java-index,Java HotSpot Virtual Machine,Specifications...