Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Runtime.getRuntime().exec question

 
Haani Naz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 15437
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Haani Naz
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An useful article to read: When Runtime.exec() won't
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic