Results 1 to 13 of 13
- 07-12-2011, 08:38 PM #1
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
how to launch and work within an external software using java
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 workLast edited by qwertyuiop415263; 07-12-2011 at 08:53 PM.
- 07-12-2011, 08:58 PM #2
Was there anything written to the error stream?it didn't work
What is the purpose of the commands String array?
- 07-12-2011, 11:41 PM #3
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
sorry it should be
Process pr = rt.exec(commands);
there is no compile time error
- 07-12-2011, 11:47 PM #4
Hard to debug code that is not what you are executing.
Was there anything written to the process's error stream?
- 07-13-2011, 05:33 AM #5
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
i only want to know how to launch a software(no gui) on command line and how to work within that software? (using java).
only help me with these lines
how to use .exec command??
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);
- 07-13-2011, 06:44 AM #6
Google "pitfalls of Runtime.exec". Your problem(s) may already be explained.
- 07-13-2011, 08:41 AM #7
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
thankx for replying..
i have already search with this key word but didn't find any useful link. actullay online tutorials only teach how to lanch softwares using java but they dont give any information about how work in these software while residing in the commnd line.
any help will be appreciated
- 07-13-2011, 08:45 AM #8
What do you mean by "work in these software"?
Are you saying that you want a Java app to launch another app such as Word and interact with it? Then I have to ask why? There is the Apache libraries that allow you to read/write Word docs, Excel spreadsheets but there is no need to actually launch Word or Excel.
- 07-13-2011, 09:20 AM #9
- 07-13-2011, 09:26 AM #10
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
YES exactly .
because the software i am using "QEMU" works only in command line. when i write qemu-system-arm.exe i enter in the qemu command line.
- 07-13-2011, 01:46 PM #11
You are not responding to this question:
Was there anything written to the process's error stream?
Also what is commands used for in your code:
String[] commands = {"cmd.exe","/c","start","-M -realview-eb-kernal",fileName};
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(fileName);
- 07-13-2011, 03:49 PM #12
Member
- Join Date
- Jul 2011
- Posts
- 6
- Rep Power
- 0
there is no error written in the error stream.
it should be
Process pr = rt.exec(commands);
instead of
Process pr = rt.exec(fileName);
- 07-13-2011, 04:08 PM #13
Similar Threads
-
Java(TM) Web Start Launcher doesn't work after a software update for some users
By Richard Gillespie in forum Advanced JavaReplies: 0Last Post: 12-21-2010, 03:21 PM -
JAVA - Principal Software Engineer (KeneXa "MNC" Product based Software Company)
By saisrinivaskenexa in forum Jobs OfferedReplies: 0Last Post: 06-19-2010, 08:11 PM -
Download Free Open Source Software lucid work for Solr
By kevi in forum LuceneReplies: 0Last Post: 03-27-2010, 11:21 AM -
Launch External Console app
By msanders in forum New To JavaReplies: 2Last Post: 12-21-2009, 03:22 PM -
How I launch an external program and kill the father?
By Dr_Misterio in forum New To JavaReplies: 2Last Post: 08-05-2009, 03:31 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks