By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,650 Members | 1,785 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,650 IT Pros & Developers. It's quick & easy.

Runtime process

P: n/a
I am trying to send a command to windows from my java program, and I get an
error.
The pertinent (?) part of my code follows:
public boolean action(Event evt, Object arg)
{ if (arg.equals("Execute")){
inputText=(String)commandText.getText();
System.out.println(inputText);
try{
Runtime rt = Runtime.getRuntime();
//Process cp1=Runtime.getRuntime().exec(inputText);
//With the Runtime instance the program is run with the exec()
method:
Process process = rt.exec (inputText);
}
catch(IOException ee){
System.err.println(ee+" can't run command");
System.exit(1);
}
}
else return super.action(evt,arg);
return true;
}

I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
Sep 29 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
jerry chapman wrote:
>I am trying to send a command to windows from my java program, and I get an
error.
If that is a CodeIsDepressedException then the solution
is easy, we have drugs to treat that, in this day and age.

If it is something else, then you might progress the thread
by *stating* the exact exception, and perhaps even listing
a stacktrace that references the code lines that led to the
probem.
The pertinent (?) part of my code follows:
A good way to make sure the code includes the
pertinent lines is to prepare an SSCCE.
<http://www.physci.org/codes/sscce.html>
...
>I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
Post an SSCCE with stacktrace.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200709/1

Sep 29 '07 #2

P: n/a
jerry chapman wrote:
public boolean action(Event evt, Object arg)
If I remember correctly, this would be the event dispatch model in Java
1.0 deprecated by Java 1.1?
I have written other java programs that successfully used this function, but
I don't know why this one doesn't work. Any suggestions?
1. Try using the more recent, non-deprecated version of the event model.
It's only been around for five versions of Java, after all.
2. After that, what exactly is the clue that it is not working? An error
message? No output? "It doesn't work" is very vague and is nearly
impossible to fix without more information.

--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Sep 29 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.