Solved

Running a windows application from Java App

Posted on 2001-06-06
5
185 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
[X]
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
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6158868
Runtime().getRuntime().exec("c:\Notepad.exe");

0
 
LVL 92

Accepted Solution

by:
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.


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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 108
jdbc error in jsp application 20 73
Opening PDF on button click and fill new document 2 54
Setup GlassFish 4 35
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

749 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