Connecting Tech Pros Worldwide Help | Site Map

Runtime process

  #1  
Old September 29th, 2007, 01:15 AM
jerry chapman
Guest
 
Posts: 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?


  #2  
Old September 29th, 2007, 07:25 AM
Andrew Thompson
Guest
 
Posts: n/a

re: Runtime process


jerry chapman wrote:
Quote:
>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.
Quote:
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>
...
Quote:
>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

  #3  
Old September 29th, 2007, 03:15 PM
Joshua Cranmer
Guest
 
Posts: n/a

re: Runtime process


jerry chapman wrote:
Quote:
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?
Quote:
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
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
What happens after runtime? rn5a@rediffmail.com answers 6 October 8th, 2007 09:25 AM
mixed assembly, unmanaged process, FreeLibrary (.NET 2.0) DPR answers 0 February 6th, 2006 01:05 AM
Bring To Front of a Process/Other application DraguVaso answers 9 November 20th, 2005 07:44 PM
Flakey Results from Runtime.exec() On Windows 2000 Hal Vaughan answers 1 July 17th, 2005 11:14 PM