• Post Reply Bookmark Topic Watch Topic
  • New Topic

JVM Instance  RSS feed

 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi,

Say I have one program Program.java.I have compiled it.And from two separate terminal I am running two "java Program".Will create two instances of JVM or two separate process within single JVM ?

Thanks,
Arka
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have two instances of the JVM running.
 
Arka Sharma
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Now if I want to create a process from a java program itself will it run on the same JVM instance on which the program running on or there will a seperate JVM for the newly created process ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you start another program by calling (for example) Runtime.exec(), and that program is a Java program, then a new process will be created with its own JVM instance.

There's a one to one relation between processes and JVM instances: in one process, one JVM instance is running. You cannot have multiple processes running as one JVM instance, or have multiple JVM instances in one process.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!