File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes  Runtime.getRuntime().exec question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " Runtime.getRuntime().exec question" Watch " Runtime.getRuntime().exec question" New topic
Author

Runtime.getRuntime().exec question

Haani Naz
Greenhorn

Joined: May 30, 2010
Posts: 23
Hi,

I'm trying to learn java atm and i figured the best way to learn it was to make a program. I'm currently in the process of making a program that functions as a launchpad for other programs. so basically you have your programs all in one pad and you can either open it one at a time or in groups etc.


I was looking for code to actually open the programs on button click and i tried the following. this does work but i don't really understand how it works.

If someone can please have the patience to explain the following to me i'd be super greatful! thanks!


Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

The exec() method of class Runtime starts an external program, it's as simple as that. What exactly do you not understand about the code?

Lookup the API documentation of the classes Runtime and Process for detailed information on what the methods do.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Haani Naz
Greenhorn

Joined: May 30, 2010
Posts: 23
Jesper de Jong wrote:The exec() method of class Runtime starts an external program, it's as simple as that. What exactly do you not understand about the code?

Lookup the API documentation of the classes Runtime and Process for detailed information on what the methods do.


Hey Jesper de Jong, thanks. I sort of understand that bit.

i'd like to know:
1. why a Process object is created but not used?
2. do you always a create a process object when starting an external program? how can that be used? an example would really help.

will read the API docs now...

If anybody's got any websites with explanations for beginners and sample programs, please share - thanks!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

An useful article to read: When Runtime.exec() won't


Mohamed Sanaulla | My Blog
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
Haani Naz wrote:1. why a Process object is created but not used?
2. do you always a create a process object when starting an external program? how can that be used? an example would really help.


You can get hold of the Process object if you want to read something back. Here is an example.
 
jQuery in Action, 2nd edition
 
subject: Runtime.getRuntime().exec question
 
Similar Threads
Runtime.getRuntime().exec
how to run dll using java
Can we call an executable(.exe) from Java program
Run a Java Program
Kill a process