Problem with Runtime.getRuntime().exec()

Hi All,

I am using

Process ps=Runtime.getRuntimetime().exe()
int exitvalue=ps.waitfor();

to execute a shell script which communicates with ftp host and prints all the folders and files to a file, I am deploying in WAS CE. If i am not used for some days the application, it is giving NullPointerException. If i restared the server and used the application it is working fine. I am not getting where the problem is can any one help me in getting the solution for this

Thanks in advance
Pavan
Gangadhara MelukoteAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Depending on how you're using Runtime.exec, it might well lock up a process stream which could turn into a NPE further down the line. See

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

and

http://technojeeves.com/joomla/index.php/free/52-runtimeexec for a solution if that's a problem
0
 
objectsCommented:
can you post the stack trace for the NPE
0
 
Gangadhara MelukoteAuthor Commented:
It is comming when there is a delay in sending request to that piece of code. At present i dont have the trace but sure it is not returning the Process Object
Thanks
Pavan
0
 
objectsCommented:
Locking up of runtime exec would not cause an NPE, it would  cause your method to not return.
Let me know when you have more info and I'll have a look at it for you
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.