This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Running 2 JVMs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Running 2 JVMs" Watch "Running 2 JVMs" New topic
Author

Running 2 JVMs

Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
This might be a stupid quesion...
How do you run your code on different JVMs on the same machine? Does this only mean to start the server in a different command line?
ie.
1. start RMI server with an IP/localhost
2. client connect using RMI
Where on the same JVM is NOT starting RMI and just instantiate your own DB object?
Thanks!
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Originally posted by Anna Kafei:

How do you run your code on different JVMs on the same machine? Does this only mean to start the server in a different command line?
ie.
1. start RMI server with an IP/localhost
2. client connect using RMI

I think you are right. Atleast my understanding is also the same.

Where on the same JVM is NOT starting RMI and just instantiate your own DB object?

I didn't quite catch this. Is it about the standalone mode?
Can you be a bit more specific?
Anna Hays
Ranch Hand

Joined: Nov 09, 2003
Posts: 131
Yes that is what I meant. Running on one JVM is standalone. ie, you get your db object when the client GUI loads. Which means, running everything by one command line.
I see the JVM is per System.exit(); like, when you type System.exit(); you will shut down the JVM. I also got this understanding from when I start an app that is done by Java and you get to give it a heap size on the JVM that determines how much memory is used by that app.
So all my understandings are just guesses, I am not sure if I am right...
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Anna,
Originally posted by Anna Kafei:
How do you run your code on different JVMs on the same machine? Does this only mean to start the server in a different command line?
ie.
1. start RMI server with an IP/localhost
2. client connect using RMI
Where on the same JVM is NOT starting RMI and just instantiate your own DB object?

Yes, you get a new JVM whenever you execute the java command from the command-line. So you can accomplish a client server configuration on the same machine by doing what you suggest: open a command window and enter "java -jar runme.jar server", and configure the server application to use localhost; and open another command window and enter "java -jar runme.jar", and configure the network client to use localhost as the database server.
Of course, running in standalone mode only requires opening a single command window and entering "java -jar runme.jar alone". Running in standalone mode only requires a single JVM. Running in server mode requires a JVM and running in network client mode requires a JVM, so if you're running the server and client on the same machine you will be running two different JVMs on that machine.


Regards, George
SCJP, SCJD, SCWCD, SCBCD
 
Consider Paul's rocket mass heater.
 
subject: Running 2 JVMs
 
Similar Threads
How to share a varible between two JVM
Network Mode, Alone Mode and Server mode
Singleton Pattern
Two or more JVM in a single machine
Jar to Send