Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Runtime process

Thread view: 
jerry chapman - 29 Sep 2007 01:09 GMT
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?
Andrew Thompson - 29 Sep 2007 07:14 GMT
>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.

Signature

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

Joshua Cranmer - 29 Sep 2007 15:08 GMT
>  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.

Signature

Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.