Solved

Problem with Runtime.getRuntime().exec()

Posted on 2011-03-16
5
622 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:Gangadhara Melukote
  • 2
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35145006
can you post the stack trace for the NPE
0
 

Author Comment

by:Gangadhara Melukote
ID: 35145145
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 35145152
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
 
LVL 92

Expert Comment

by:objects
ID: 35145171
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 35296506
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 28
nextBoolean(double p) for Random class 3 35
Oracle SQL syntax check  without executing 6 37
MySqlDump not dumping triggers 1 18
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now