0

It's possible to run double JVM on one computer? Then how to do?

Zeck
  • 6,433
  • 21
  • 71
  • 111

5 Answers5

3

A JVM is simply a process. You just start the JVM.

groundhog
  • 4,770
  • 2
  • 24
  • 24
3

Running two JVM? Just run the java twice, starting the same or different applications. What exactly you're trying to achieve?

yclian
  • 1,490
  • 14
  • 22
3

Here's a simple example:

$ java -jar SwingSet2/SwingSet2.jar ; java -jar Java2D/Java2D.jar

Addendum: Here are two more complex examples: a command line program to start/stop a GUI program in a separate JVM; a Swing program to start/stop a different Swing program in a separate JVM.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
3

If what you're looking for is being able to run two different versions of the JVM, say you have an app that's been tested with a given version, say 1.4.y, but you want to experiment with a newer version, say 1.6.21, you need to set your JAVA_HOME environment variable. This tells your system where to look for java.

In linux/bash it's as easy as adding the following to your bashrc, or the shell script that runs your app:

JAVA_HOME=/path/to/toplevel-jvm-dir

Here's a link for windows Setting JAVA_HOME via GUIs and batch:

set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07
Paul Rubel
  • 26,632
  • 7
  • 60
  • 80
0

If you referring to JVM IMPLEMENTATION : Yes you can have multiple installations in your machine. Just install multiple JREs.

OR

Referring to JVM RUNTIME INSTANCE : Each application gets its own JVM instance. So just run 2 applications and you will get 2 JVM instances.

Eg : deploy two war files in tomcat. In this case there are 2 JVM instances in a single JRE.

rai.skumar
  • 10,309
  • 6
  • 39
  • 55