Starting a new process

Hi

I want to write a jar file to start the tomcat server and run certain tests on our application. Both the process is running properly when I execute it individually.

THe problem is when I try to run them together -the TOMCAT server starts and the control does not return to the JRE.. When I stop the server the test application starts.

How can I do it ?

PLS help

[395 byte] By [New_Kida] at [2007-11-27 5:59:38]
# 1
How can I run a second process from the same java file ?
New_Kida at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 2
check Runtime API
AnanSmritia at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 3
> check Runtime APII couldn't find anything useful !!The program is not proceeding after the 1st process starts. Only when I shut down the server the 2nd process is starting.
New_Kida at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 4
It sounds like you need to start the processes in separate threads.
sabre150a at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 5
Can u tell me how exactly ?
New_Kida at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 6
You can spawn a separate process from a Java program but you have to take care of the stdin and especially stdout, stderr streams.
BIJ001a at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...
# 7

Hi,

1) To start an external process:

Runtime rt = Runtime.getRuntime();

Process proc = rt.exec(cmd);

where cmd is (in the simplest case) a String (path+exe name of the executable) or an array of Strings (in case the executable also needs some start parameters).

2) To create a thread:

public class MyThread extends Thread

{

public void run() {

// place your code here (Runtime... see above point 1)

}

}

in your main class:

MyThread t = new MyThread();

t.start();

For details pls have a look at the documentation of Runtime and Thread.

regards

BugBunny

BugBunnya at 2007-7-12 16:36:27 > top of Java-index,Java Essentials,Java Programming...