Runtime.getRuntime.exec() + SWT oder Swing = geht nicht

Status
Nicht offen für weitere Antworten.
D

dll++

Gast
Hi,

ich möchte die Methode Runtime.getRuntime.exec() benutzen und damit einen Server und Clients starten,
aber diese starten erst, wenn ich des Fenster (egal ob SWT- oder Swing- oder AWT-Fenster) schliesse.

Was mache ich falsch ?

Muss ich etwa einen Outputstream flushen, oder wie ?

Bin völlig verzweifelt.

Bin dankbar für jede Hilfe.

Gruss.
 
G

Guest

Gast
Code:
package snippets;

import java.awt.*;
import java.io.*;
import javax.swing.*;

public class Swing extends JFrame{
	
	private static String[] serverCommand = { "cmd.exe", "/C", "AiServer.exe -start -lvl=20 -port=16713" };
        private static String[] clientCommand = { "cmd.exe", "/C", "java -jar NICE.jar localhost 16713 Client" };
	
	public static void main(String[] args) {
		final Swing s = new Swing();
		s.setVisible(true);
		s.setLayout(new GridLayout(4,2,6,3));
		JButton b = new JButton();
		b.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				 try {

					Runtime.getRuntime().exec(serverCommand, null,
							 new File("C:\\Dokumente und Einstellungen\\Administrator\\" +
							 		"Desktop\\Diplomacy\\Server\\aiserver\\"));
					 Runtime.getRuntime().exec(clientCommand, null,
							 new File("C:\\Dokumente und Einstellungen\\Administrator\\Desktop\\"));

					 Runtime.getRuntime().exec(clientCommand, null, 
							 new File("C:\\Dokumente und Einstellungen\\Administrator\\Desktop\\"));
				 } catch (IOException e1) {
					e1.printStackTrace();
				}
			}
			
		});
		b.setText("Start");
		s.add(b);
		s.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
		s.setBounds(200, 200, 400, 200);
	}
}
 
Status
Nicht offen für weitere Antworten.

Oben