Running a windows application from Java App

Hello,

I'm messing about with Swing for the first time and I'd like to create a Desktop toolbar.  How can I tie a button to a Command String like "C:\Notepad.exe" ??  Don't worry about the button side of the code ... I'd just like to find out how I can get a Java app to invoke such a call on the Operating System.

Any ideas are warmly welcomed !!

Rob.
robertod031297Asked:
Who is Participating?
 
objectsConnect With a Mentor Commented:
It returns a Process object which can then use to do such things as:
- check on the process status
- get input/output stream
- kill it

Pls refer to the javadoc :)

Let me know if you need any more info.


0
 
objectsCommented:
Runtime().getRuntime().exec("c:\Notepad.exe");

0
 
robertod031297Author Commented:
That's just what I was after ...
Thanks Objects (??interesting name??),
0
 
OviCommented:
public class AppRunner {
     public static void main(String[] args) {
          String app = "notepad AppRunner.java";
    try {
         Process process = Runtime.getRuntime().exec(app);
    } catch(Exception e) {}
     }
}
0
 
objectsCommented:
> Thanks Objects (??interesting name??),

Company name, http://www.objects.com.au
0
All Courses

From novice to tech pro — start learning today.