qwertyuiop415263
Full Member level 4
hello. I am new to java and using eclipse IDE. i have a software known as QEMU which work only on command line i.e no gui and we have to work in this software from command line e.g i write this line "qemu-system-arm.exe -M realview-eb -kernel D:\test.out -serial file:test.out" on command line its works fine. now i have to lanch this command using java. here is my code import java.util.*; import java.io.*; public class Command{ public static void main(String args[]) { try { String fileName = "C:\\Documents and Settings\\Ali\\Desktop\\qemu-0.13.0-arm-win32\\qemu-system-arm.exe"; String[] commands = {"cmd.exe","/c","start","-M -realview-eb-kernal",fileName}; Runtime rt = Runtime.getRuntime(); Process pr = rt.exec(fileName); BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream())); String line=null; while((line=input.readLine()) != null) { System.out.println(line); } int exitVal = pr.waitFor(); System.out.println("Exited with error code "+exitVal); } catch(Exception e) { System.out.println(e.toString()); e.printStackTrace(); } } } but it didn't work