aspose file tools*
The moose likes Performance and the fly likes More than one Java App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "More than one Java App" Watch "More than one Java App" New topic
Author

More than one Java App

ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
Will running three instances of javaw.exe really slow down performance?
The reason I asked is that I was once tasked to write a Java Instant message system for our team. It runs a receiver and a sender. (The sender is excecuted in a seperate javaw instance which I am thinking about modifying).
I have now been tasked with writing another java app that is to be up and running all the time as well.
How will something like this affect 800Mhz machines with 128MB of RAM.
I don't wanna be bogging down the teams machines.


Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Yes. Each JVM is a seperate process and will use it's own memory space. This means, for example, that a class, like java.lang.Object will be loaded into the memory spaces of each JVM.
You can run multiple application in the same JVM. Basicially, you create your own classloader. When you start an app, it checks to see if there's already a JVM running, and if so, makes sure that JVM spawns a new thread and runs the new application. Obviously the first JVM to start up needs a way to announce itself in ways future programs can check when they start up.
I know there are solutions out there which do this. I think one of the Java Magazines even gave an exmaple back in 2000. I would also guess that Star Office does something like this.

--Mark
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
guess I am not quite up to speed on that.
Not really sure what you mean.
Do I have something in one program that calls the other one?
What if the two apps have nothing to do with each other, is this still possible??
Kirk Pepperdine
Author
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
Originally posted by ryan headley:
guess I am not quite up to speed on that.
Not really sure what you mean.
Do I have something in one program that calls the other one?
What if the two apps have nothing to do with each other, is this still possible??

I believe what Marc was trying to describe is a means to run multiple applications in the same VM by running each application in it't own class loader. I'm not sure how Marc believes you can achieve this but here is one scheme that should work.
First, you need two things, an appliction that you could communicate with and possibly, a custom ClassLoader. What you'd pass to this application is the name of an application that you want to execute. The application would then start the application in a new ClassLoader.
One of the potential problem with this approach is that (I believe ) System.exit() causes the VM to exit.

Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0672324261/ref=jranch-20" target="_blank" rel="nofollow">Ant Developer's Handbook</a>
Kirk Pepperdine
Author
Ranch Hand

Joined: Jan 17, 2001
Posts: 71
Originally posted by Kirk Pepperdine:
[B] I believe what Marc
[B] Oops, that should have been Mark. Sorry Mark 8^\
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I think I've gotcha. The main app should be something where you would select which app to run...at least that is what I am seeing.
In order to get around the System.exit() I suppose you could just .dispose the things you aren't using...
Dunno.
Mark Herschberg
Sheriff

Joined: Dec 04, 2000
Posts: 6037
Yes, that's basically it.
I don't think you can override System.exit you(), so need to be sure to never call it from any of your applications. So how do you shut down an application? As follows....
In addition to each application code, there is also some shared Java code. This is a manager class. When a system wants to quit, it lets the manager know. The manager then keeps tract of whether or not it is the last application running, and if it is, the manager calls System.exit(). If it is not the last application, the manager can also tell the classloader to unload the classes (if supported by that version of Java).

--Mark
ryan headley
Ranch Hand

Joined: Jun 28, 2000
Posts: 156
I think I smell what yer cookin...thanx
Jack Shirazi
Author
Ranch Hand

Joined: Oct 26, 2000
Posts: 96
I wrote an article on this:
Multiprocess JVMs. It references the Echidna project which should give you everyting you need.
-Jack Shirazi
http://www.JavaPerformanceTuning.com/
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
Interesting article. But shouldn't the Process class implement Runnable?

Originally posted by Jack Shirazi:
I wrote an article on this:
Multiprocess JVMs. It references the Echidna project which should give you everyting you need.
-Jack Shirazi
http://www.JavaPerformanceTuning.com/

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: More than one Java App