RunTime exec configuration for the child

P

puzzlecracker

if I want to run a java application from the same java application:
meaning parent process spawns a child process, but passes different
parameters (to avoid infinite spawning); does the child inherits
parent's classpath and other configurations
or do I need to pass the classpath along?

If I am using linux env. and exported the classpath, will it be used.

Basically, I want the application to run on win32 (eclipse) and Linux.

Also, child process does a lot of printing, should create another
thread to monitor and read its output or what?

what is the general pattern for this kind of a thing.

Suggestions and examples will be appreciated.

Thanks

ps.I was trying to do something with listerner but cannot get printing
to work.....
 
C

Chris Smith

puzzlecracker said:
if I want to run a java application from the same java application:
meaning parent process spawns a child process, but passes different
parameters (to avoid infinite spawning); does the child inherits
parent's classpath and other configurations
or do I need to pass the classpath along?

If you've specified the classpath via the "-classpath" command line
option, then you'll need to repeat that on the child process. If you've
specified it with the CLASSPATH environment variable, that will be
inherited by the child process by default.

It's important to note that there's no special case in Process for
invoking another JVM. You have to do it just like you would any other
process, and it follows the same rules.
Also, child process does a lot of printing, should create another
thread to monitor and read its output or what?

By printing, I assume you mean writing to the console (as opposed to
using a printer, for example). Yes, you will need to read from the
resulting streams eventually, so the child process doesn't block
indefinitely.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,362
Latest member
OrderTrimKetoBoost

Latest Threads

Top