Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Running a windows application from Java App

Posted on 2001-06-06
5
Medium Priority
?
199 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
ID: 6158868
Runtime().getRuntime().exec("c:\Notepad.exe");

0
 
LVL 92

Accepted Solution

by:
objects earned 800 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.


0
 

Author Comment

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

Expert Comment

by:Ovi
ID: 6159413
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
ID: 6161904
> Thanks Objects (??interesting name??),

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

773 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