How many JVM could be run on an single Machine

We can run as many JVM instances as we want on an OS. When ever we start a new java process by invoking java.exe (i.e. java [class-name] ) a new instance of JVM is created. Each java process executes in its separate JVM environment - we can specify different JVM parameter for each process.

If it was not possible to execute more than one JVM instance or in other words if all java processes were made share the same JVM instance, then we would not have been able to specify separate JVM options for every processes.

Also, this provides a security feature for each java process, as it executes in its separate environment controlled by the JVM options provided during its start.

A good example of it is Java RMI. RMI is used for communication between two JVMs. Even on a single machine we need to use RMI to communicate between different java processes, that explains that they are not sharing the same JVM instance.

Now, many people are of the opinion that we can have only one JVM as we can install only one JVM type on an OS. This is same as saying that we can open only one MS-Word document coz we can install only one office suit. (Well, not exactly, we can have multiple office suits installed - in different directories).

Also to say, whenever we do a java install, we do not install a JVM, we either install a JRE or JDK. And we can install multiple JRE/JDK on the same machine and also use them simultaniously run our programs - by providing specific paths during program start.

0 comments: