Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Respawn a new virtual machine from within a running java programm?

64 views
Skip to first unread message

Heinrich Götzger

unread,
Dec 17, 2002, 10:43:47 AM12/17/02
to
Hi,

is there a way to restart/spawn a new idependent java VM from within
an existing and running java thread?

My goal is to have one single class which uses singleton in a third
party jar which I'm not getting a hold of (programmwise). But I need
two independend instances at the same time because they work with two
different settings.

There is now way for me to start two seperate processes. In fact the
systems works with two seperate processes, but this is only possible
in my development environment. Not for the final user.

If you have some link to look up or some working solution, please let
me know.


Thank you very much.

Kind regards

Heinrich Götzger

Ingo Pakleppa

unread,
Dec 18, 2002, 8:43:37 AM12/18/02
to
A separate VM is always a separate process; there is a hardcoded
limitation in the JVM that says "only one JVM per process". If you want to
start a separate JVM, you can do that using System.Runtime.exec(). Of
course, this will be a completely separate entity, if they need to share
data, they would have to use something like RMI to communicate.

You may also want to see if playing around with the class loaders may
help; you might be able to fool Java into thinking that the third-party
class is really two separate classes if they are loaded by separate
classloaders. There could be subtle problems with that approach, though.

Heinrich Götzger

unread,
Dec 19, 2002, 4:26:55 AM12/19/02
to
It works fine with System.Runtime.exec() but only with Linux, not with Windows.

The third party class is a CORBA NameService and once the ORB is initialized,
it can't be used somewhere else in this process due to being a singleton.

Thanks

cheers

Heinrich


"Ingo Pakleppa" <ingo-imm...@kkeane.com> wrote in message news:<dY_L9.133$6k.1...@news1.west.cox.net>...

Ingo Pakleppa

unread,
Dec 19, 2002, 12:21:07 PM12/19/02
to
What is the problem in Windows? A name service can most likely run in a
separate process without a problem - in fact, that may be a better
approach, since the functionality is probably not intrinsic to the main
application.

Heinrich Götzger

unread,
Jan 7, 2003, 1:24:23 PM1/7/03
to
Ingo,

thanks for the reply. Sorry for not answering earlier. Had a loooong
XMas Break ;-)

The problem (my whish) is, that I like to have a jUnit test running
the CORBA servant, the NameService and the CORBA Client 'narrowing'
the servant from one single call. This is to check that the client
works against the specified server interface and its namingdirectory.

If I run all these three processes seperate, it works fine. Even on
Windows ;-)
But how to put it in jUnit, which is the actual problem, not the
respawn which I consider as one potential solution.

If you have a good other working solution for this, please let me
know.

Thanks

cheers

Heinrich


"Ingo Pakleppa" <ingo-imm...@kkeane.com> wrote in message news:<7enM9.8657$6k.4...@news1.west.cox.net>...

Heinrich Götzger

unread,
Jan 14, 2003, 5:50:40 AM1/14/03
to
!!! Admin question !!!
1. Where is my posting to this group from Tue, 7 Jan 2003 10:24:24
-0800?
2. Why does the webinterface with google indicating 5 postings, if it
shows
only 4, and why does the 5th posting (see above) not appear?
3. Where are all postings from January 3 of 2003 till January 8 of
2003 of this
group. They don't appear in my browser:
see this list:
8 Jan. 2003 Can somebody understand this Java script (5 Beiträge)
vasanta
8 Jan. 2003 Looking for embeddable XML editor written in Java (2
Beiträge) Stephen Ostermiller
<here is the gap>
3 Jan. 2003 help with chat application + emoticon (2 Beiträge)
Isabelle
3 Jan. 2003 Newbie: XP commandline doesn't detect Sun JVM (4
Beiträge) James Taylor
3 Jan. 2003 Not even James Goslin can Answer this... (9 Beiträge) TK
3 Jan. 2003 insert table that was a complete program... (4 Beiträge)
TK


The content of my posting was:

Ingo,

thanks for the reply. Sorry for not answering earlier. Had a loooong
XMas Break ;-)

The problem (my whish) is, that I like to have a jUnit test running
the CORBA servant, the NameService and the CORBA Client 'narrowing'
the servant from one single call. This is to check that the client
works against the specified server interface and its namingdirectory.

If I run all these three processes seperate, it works fine. Even on
Windows ;-)
But how to put it in jUnit, which is the actual problem, not the
respawn which I consider as one potential solution.

If you have a good other working solution for this, please let me
know.

Thanks and kind regards

Heinrich

0 new messages