package org.tizen.emulator.skin;
+import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import org.tizen.emulator.skin.menu.KeyWindowKeeper;
import org.tizen.emulator.skin.menu.PopupMenu;
import org.tizen.emulator.skin.screenshot.ScreenShotDialog;
+import org.tizen.emulator.skin.util.IOUtil;
import org.tizen.emulator.skin.util.SkinUtil;
import org.tizen.emulator.skin.util.SwtUtil;
try {
SkinUtil.openMessage(shell, null,
"Control Panel file does not exist in the following path.\n"
- + ecpFile.getCanonicalPath(),
+ + ecpFile.getCanonicalPath(),
SWT.ICON_ERROR, config);
} catch (IOException ee) {
logger.log(Level.SEVERE, ee.getMessage(), ee);
}
return;
- }
+ }
- String emulName = SkinUtil.getVmName(config);
- int portSdb = config.getArgInt(ArgsConstants.VM_BASE_PORT);
+ String emulName = SkinUtil.getVmName(config);
+ int portSdb = config.getArgInt(ArgsConstants.VM_BASE_PORT);
ProcessBuilder procEcp = new ProcessBuilder();
procEcp.redirectErrorStream(true);
- File nullFile = null;
// FIXME: appropriate running binary setting is necessary.
if (SwtUtil.isWindowsPlatform()) {
procEcp.command("java.exe", "-jar", ecpPath, "vmname="
+ emulName, "base.port=" + portSdb);
- nullFile = new File("NUL:");
} else if (SwtUtil.isMacPlatform()) {
procEcp.command("java", "-jar", "-XstartOnFirstThread",
ecpPath, "vmname=" + emulName, "base.port="
+ portSdb);
- nullFile = new File("/dev/null");
} else { /* Linux */
procEcp.command("java", "-jar", ecpPath, "vmname="
+ emulName, "base.port=" + portSdb);
- nullFile = new File("/dev/null");
- }
- if (nullFile != null) {
- procEcp.redirectOutput(ProcessBuilder.Redirect.to(nullFile));
}
logger.info(procEcp.command().toString());
+ Process proc = null;
try {
- procEcp.start(); /* open ECP */
+ proc = procEcp.start(); /* open ECP */
} catch (Exception ee) {
logger.log(Level.SEVERE, ee.getMessage(), ee);
SkinUtil.openMessage(
"Fail to open control panel : \n" + ee.getMessage(),
SWT.ICON_ERROR, config);
}
+
+ if (proc != null) {
+ final InputStream in = proc.getInputStream();
+ final BufferedReader br = new BufferedReader(
+ new InputStreamReader(in));
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ while (br.readLine() != null) {
+ // do nothing
+ }
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ } finally {
+ IOUtil.close(in);
+ }
+ }
+ }).start();
+ }
}
};