This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Java as a child process  RSS feed

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was trying a sample program to run another java file from my java file using Runtime.exec(). Here's the code for the sample program




Can anyone tell me why this happens? Is there an alternative to achieving the task
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try reading the ErrorStream and InputStream of the Process instance. you should see the program output or any error in those.
 
Vishal Shaw
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stuart A. Burkett wrote:Try reading the ErrorStream and InputStream of the Process instance. You should see the program output or any error in those.



Thanks , it works now. But , can you tell me why we get the stream as a separate one . I thought that the child process can share the stream with the parent process, But this does not seems true in this case.

Also there's one more problem, when I apply the same thing to a swing/webapp as the parent process, then it seems the parent terminates the child process without waiting for it to complete. So, how to achieve this stuff in a swing/webapp? Do I need to pause the parent Thread explicitely?
 
Rancher
Posts: 1017
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Vishal Shaw wrote:can you tell me why we get the stream as a separate one



Sometimes you will need the stdout and stderr outcome of the child process, so there must be a way to capture it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!