Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Runtime.getRuntime().exec question  RSS feed

 
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!


 
Java Cowboy
Sheriff
Posts: 16082
88
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!
 
Bartender
Posts: 3185
34
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
 
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
Boost this thread!