File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Need help running multiple apps on same JRE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need help running multiple apps on same JRE" Watch "Need help running multiple apps on same JRE" New topic

Need help running multiple apps on same JRE

Matt Senecal
Ranch Hand

Joined: Dec 01, 2000
Posts: 255
I've written an application that serves as a floating desktop "button bar" (call it MyApp). The requirements for it were that:
1. All the java applications launched from it had to all run on the same JRE
2. MyApp had to be completely ignorant of the applications it would be launching. That is, when MyApp runs, it reads a prefs file to get information (location, class names, etc.) on the classes it will have to load.
An application's main class is loaded like so:

The application is launched like this:

The application is launched by MyApp (and MyApp retains no reference to it at all). Technically, the launched application is running as a seperate process on the JRE (a thread launched by MyApp), but the effect is the same. So far, so good.
PROBLEM: I had to implement a custom SecurityManager that prevented a quitting application (using System.exit()) from killing the JRE (and hence all the other Java apps). Side effect: the application stops running, but the memory it used isn't reclaimed. MyApp has no refence to the application that
was launched, and can't explicitly kill it. Hence MyApp is a slow, and potentially very large, memory leak. Not good.
Does anyone know of another way to do this? A method that would keep a reference to the launched processes so they could be explicitly terminated? Is there a way for my custom SecurityManager to get a handle on the process that initiated the System.exit()? Any help would be appreciated.

[This message has been edited by Matt Senecal (edited July 30, 2001).]

There's nothing more dangerous than a resourceful idiot. ---Dilbert
Mark Herschberg

Joined: Dec 04, 2000
Posts: 6037
Matt, this start bar idea sounds very familiar to me; I think I read about it in a book or on some website. Maybe other people have done this and a little searching may turn up their results. You may also want to look into JumpStart/WebStart, as they may have played around with similar ideas, and encountered some of these issues.
I agree. Here's the link:
subject: Need help running multiple apps on same JRE
jQuery in Action, 3rd edition