Running a windows application from Java App

Posted on 2001-06-06
Last Modified: 2010-03-31

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 !!

Question by:robertod031297
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 92

Expert Comment

ID: 6158868

LVL 92

Accepted Solution

objects earned 200 total points
ID: 6158873
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.


Author Comment

ID: 6158925
That's just what I was after ...
Thanks Objects (??interesting name??),

Expert Comment

ID: 6159413
public class AppRunner {
     public static void main(String[] args) {
          String app = "notepad";
    try {
         Process process = Runtime.getRuntime().exec(app);
    } catch(Exception e) {}
LVL 92

Expert Comment

ID: 6161904
> Thanks Objects (??interesting name??),

Company name,

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
check java version using powershell 13 473
Why doesn't this text field show up on my Applet frame? 2 43
java example issue 5 67
passing enum to a method 4 52
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question