Solved

Running a windows application from Java App

Posted on 2001-06-06
5
152 Views
Last Modified: 2010-03-31
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.
0
Comment
Question by:robertod031297
  • 3
5 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
Runtime().getRuntime().exec("c:\Notepad.exe");

0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
Comment Utility
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
 

Author Comment

by:robertod031297
Comment Utility
That's just what I was after ...
Thanks Objects (??interesting name??),
0
 
LVL 9

Expert Comment

by:Ovi
Comment Utility
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
 
LVL 92

Expert Comment

by:objects
Comment Utility
> Thanks Objects (??interesting name??),

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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Enhanced For loop vs ForEach Loop 4 54
array6 challenfge 6 62
topping1 challenge 7 48
wordappend challenge 8 83
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now