Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run external application when jbutton clicked?

Status
Not open for further replies.

Tarnish

Technical User
Nov 13, 2006
221
0
0
US
Hi all,

I'm new to java. I need to start an external application when a jButton is pressed. I have the button, it's event listner, and the actionPerformed method that will run code based on which button is pressed.

Now all I need is the actual code to run to get an external app to open! Can anyone help? Remember, I'm new, so the more specific the instructions the better...specifically which code goes where. I have a couple of books on Java, and have done some searches here and on google. I just can't seem to get the answer I need on this seemingly simple thing.

Thanks, in advance. Sorry for what I'm sure is a very 'noob' and frequently asked question.

Thanks,
T
 
Take a look at the Runtime class, specifically, the exec() method:
public Process exec(String command)
throws IOException

Executes the specified string command in a separate process.

The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call:

new StringTokenizer(command)


with no further modifications of the character categories. This method has exactly the same effect as exec(command, null).

Parameters:
command - a specified system command.
Returns:
a Process object for managing the subprocess.

_________________
Bob Rashkin
 
HI Bong,

Thanks a ton for your reply.

I had actually previously found that class/method and looked it up in the API. I'm just not proficient enough at this point to translate that into a real world answer....

Thanks for the heads up, though.
T
 
I finally got it to work. Thanks again!
T
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top