0

I am developing java program. In program I am calling shell script and creating files from shell scipt. When I am trying to access created file it has not been created. so It creates file late. so how to overcome this problem?

Divyang Shah
  • 1,578
  • 1
  • 11
  • 22

1 Answers1

2

There is a need for more information (source if you have it for instance) but it sounds that you are not waiting for the shell script to finish. It sounds like they run in parallell, that your Java program just creates the shell and runs it in another thread. Look for the shell thread and do threadObj.join() it (or if you use process = Runtime.getRuntime().exec("echo Hello world"), you need to do process.waitFor()).

Aquaplanet
  • 563
  • 4
  • 14
  • hello Aquaplanet, Thanx for suggestion. but, I have already tried process.waitFor(). but it didn't work for me. I got solution. I made sleep 25 in shell script and it worked for me. – Divyang Shah Nov 21 '14 at 06:30