This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am beginner to Java and J2EE, I have one doubt regarding JVM
Can one JVM be employed for running mutiple java programs,Why am i asking this Question means,As we know servletContainer, JSPContainer and EJB Container running in a server,Each of these container is a compliled and executed programme,So Server itself is holding all these programs simultaneously to handle requests with single JVM..How is it possible? If any one clarifies this doubt i will be very thankful.
Well, it depends on your definition of "program". In the case of a Web server, I would say there is just one program - the Web server - which runs a whole load of Web applications. But that's just my take on it.
In fact, though, one JVM can be used to run a number of totally separate, unconnected applications. The "java" executable that is usually used to launch a Java program is not the only way to run Java code. Using the Java Invocation API, you can use native (typically C/C++) code to instantiate a JVM, load classes, start threads, run methods etc. You could write your own launcher program that ran as many separate Java applications as you liked.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Sep 27, 2006
Thank You Mr.Peter,
I got the answer for my question, here webserver itself is a program that runs multiple programs like servletContainer,JSPContainer,...etc and some otherthings.
Sounds like you got an answer to your particular question, but let's generalize it a bit. To run one "program" you usually say
which runs Program1.main(). There's nothing to prevent us from writing Launcher.java that does:
Now is it running three programs or one? That's the tricky bit about defining "program." They'll all share "global" resources in the JVM like memory space, static variables and connection pools and such. Is that good or bad? Depends on how the "programs" are designed.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
String s=new String; s="A"; s="C"; SubTest.main(s); MyInterface.main(s); System.out.println("Subtest Called"); MultipleMains.main(s); } In the above code i have called 3 main() methods but only MultipleMains.main(s) is executed.The rest of the two main() methods are not executed,May i know the reason Why?Can anybody clarify my doubt?