This is basically the layout of my task at hand:

I have one "host" program - the basic GUI for the entire application running at any given time. It contains a JTabbedPane. When the user adds a tab, I want the program to start a completely new process (new JVM and all) and return the JPanel created from the process. Communication between the two processes is extremely preferable, though not completely necessary (event-driven communication would be wonderful, but that's a long shot).

I tried one method (among other similar methods) that all ran into similar exceptions.
Essentially, when the host creates the process, it creates an ObjectInputStream from the System.out of the new process and reads a JPanel object (while the new process writes the JPanel to System.out via ObjectOutputStream).

What happens when I try this, is that some of the components in the JPanel are loaded from different classes that is known to only the new process. The host process cannot define the classes because it has no access to them.

Something like the Google Chrome architecture would be nice, where each tab is in a separate process, and the main frame is only a tabbed pane with a add tab button. Any advice/help/links/code segments are appreciated.

Why a new JVM?

Because I am using a remote application in each JVM process. Default thread naming has the numbers going up to where it is obvious that multiple instances of that remote application are running. I have to keep the threads in separate JVMs but I want them to communicate as if they were in the same JVM.

The easiest way is probably to use Sockets to establish a 2-way communication between the running apps. That also has the advantage that it works exactly the same if one of the apps is moved to a different computer. There are "better" solutions, eg RMI, but they come with a significant overhead in terms of learning and setup.

I already learnd and tried tried RMI and local connections, but the problem is that the classes in the remote application do not implement Serializable, so I can't do that unless I implement a custom protocol using just the Reflection API and Class<?> objects. Oh well...thanks anyway.

If the classes conform to javabean specs you could maybe use XMLEncoder/Decoder?

Hmm, good idea, but it failed with some InstantiationException (sometime ago). I decided to do it my own way, and I'm implementing my own custom ObjectLoader using the sun.misc.Unsafe class and the Reflection API. Thanks for the help anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.