Tscott84
asked on
Trying to pinpoint why I keep getting this error while executing client Server application Exception in thread "Thread-0" java.lang.NullPointerException
I get this error Exception in thread "Thread-0" java.lang.NullPointerExcep tion
at java.lang.Runtime.exec(Run time.java: 424)
at java.lang.Runtime.exec(Run time.java: 328)
at ClientProcess.execProcess( P1Server.j ava:98)
at ClientProcess.run(P1Server .java:69)
at java.lang.Thread.run(Threa d.java:619 )
Evertime my server sends my client a message/reply......I am trying to pinpoint
the problem and am lost....I would greatly appreciated if someone could give some insight......Thanks
at java.lang.Runtime.exec(Run
at java.lang.Runtime.exec(Run
at ClientProcess.execProcess(
at ClientProcess.run(P1Server
at java.lang.Thread.run(Threa
Evertime my server sends my client a message/reply......I am trying to pinpoint
the problem and am lost....I would greatly appreciated if someone could give some insight......Thanks
ASKER
ok Im going to check it out thanks for responding so fast
ASKER
at line 98 I am beginning my try catch......I still dont see any thing that sticks out to me
private void execProcess(String aCommand)
{
try
{
Runtime runtime =Runtime.getRuntime();
Process p = runtime.exec(aCommand);
BufferedReader in = new BufferedReader
(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
{
toClient.println(line);
}//end while
}
catch (IOException e)
{
e.printStackTrace();
}//try-catch
}//end execProcess()
}//end Client Process
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok im gonna check it out
ASKER
ok echoe printed my clientReq/aCommand twice
once in my run() and once in my execProcess
and this my result so yeah it is null but I am getting the results on my client Side
uptime
uptime
null
null
02:49:17 up 73 days, 11:28, 1 user, load average: 0.07, 0.06, 0.07
once in my run() and once in my execProcess
and this my result so yeah it is null but I am getting the results on my client Side
uptime
uptime
null
null
02:49:17 up 73 days, 11:28, 1 user, load average: 0.07, 0.06, 0.07
Exception in thread "Thread-1" java.lang.NullPointerException
at java.lang.Runtime.exec(Runtime.java:424)
at java.lang.Runtime.exec(Runtime.java:328)
at ClientProcess.execProcess(P1Server.java:100)
at ClientProcess.run(P1Server.java:70)
at java.lang.Thread.run(Thread.java:619)
ASKER
hey thanks I think I got it took the while loop out it was like looping and the clientReq
was continously getting read by the execProcess even after it was read ...thats why
my client was getting the reply but the second time it was read my aCommand was null
so............THANKS ALOT
was continously getting read by the execProcess even after it was read ...thats why
my client was getting the reply but the second time it was read my aCommand was null
so............THANKS ALOT
check line 98 of P1Server
check what parameters you are passing to exec.