• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

More than one Java App

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Author
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Kirk Pepperdine
Author
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kirk Pepperdine:
[B] I believe what Marc
[B] Oops, that should have been Mark. Sorry Mark 8^\

 
ryan headley
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I smell what yer cookin...thanx
 
Author
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic