problem with exec(), subprocess starts after main process
I have a problem. I must create a subprocess and connect to it with socket.
0. String command_to_exec_subprocess="java -cp"+cp+" mypackage.MyMainClass "+args;
1. Runtime.getRuntime().exec(command_to_exec_subproce ss);
2. socket.connect(new InetSocketAddress("localhost",25000), 3000);
1. ServerSocket server=new ServerSocket(25000);
JFrame jf=new JFrame();
2. Socket client=server.accept();
I use: Windows 7
Problem is that frame popsup after my process finished, socket can never connect to server socket. As far as I know this means that Runtime waits with starting subprocess till my main process ends... Does any one know how to make the process execute just after I use exec command?? I tryed to use ProcessBuilder but when I use it it doesnt even start the subprocess... When i run the command from cmd on windows7 it runs with no problem.