aspose file tools
The moose likes Beginning Java and the fly likes  Runtime.getRuntime().exec question Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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
Bartender

Joined: Aug 16, 2005
Posts: 12907
    
    3

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
Bartender

Joined: Sep 08, 2007
Posts: 2925
    
  15

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.
 
I agree. Here's the link: jrebel
 
subject: Runtime.getRuntime().exec question
 
Similar Threads
Can we call an executable(.exe) from Java program
how to run dll using java
Kill a process
Runtime.getRuntime().exec
Run a Java Program