File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes how to launch two JVM executing two java programs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to launch two JVM executing two java programs" Watch "how to launch two JVM executing two java programs" New topic

how to launch two JVM executing two java programs

Arun Gupta

Joined: Aug 29, 2006
Posts: 5
I want to launch two different JVM, each one is executing a java program. Can any one suggest me how to do this
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
You just run "java" twice, with the appropriate arguments.

Or do you mean that you want two JVMs in the same process? If so, that's probably possible, but you would need to launch the JVMs using your own native code and the Java Invocation Interface.

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
The number of java processes you create is the number of JVM's running at that point of time.

Say I run a time consuming program from console like

java MySampleProgram

then I open my eclipse and then I start my tomcat instance.So at this point of time I have three jvm's for each of the processes.

So if I investivage the current process running then I would find that there are two instances of java and one of javaw (used by eclipse).

Rahul Bhattacharjee
LinkedIn - Blog
Paul Clapham

Joined: Oct 14, 2005
Posts: 19867

I am guessing that Arun wants to run two different versions of Java (e.g. Java 1.4.2 and Java 5). This would be done by setting the PATH variable suitably, or by hard-coding the path to the java.exe file.
Srinivas Kalvala
Ranch Hand

Joined: Oct 20, 2005
Posts: 257

Hello Arun,

Can you give more inputs regarding your requirement?
I agree. Here's the link:
subject: how to launch two JVM executing two java programs
It's not a secret anymore!