Java Runtime.getRuntime().exec not returning any value
Hi,
i written class like this but it is not returning any results and infact p.waitFor() is returning value 1. This is very basic program that i am planning to run in unix. This is really killing my time and unable to find correct reason.
----------------------------------------------------------------------------------
---------------------------------------------------------------
Appreciate for your help
Last edited by Franklin52; 12-12-2014 at 08:47 AM..
Reason: Please use code tags
First, you need to read both stdout and stderr streams from the process before you call waitFor(). If you don't, your child process could block/hang or even fail to run at all as it's output can't go anywhere. How do you read two streams and then call waitFor()? Multiple threads is the way I've seen it done most often.
Second, typing a command in an interactive shell isn't necessarily the same as running it as a subprocess. You may need to escape your "!" character in your Java string.
I kept it simple and was able to run this code without error after I substituted CMD for something simpler like ls so it could very well be that you may need to quote special characters. The first thing that stood out to me in your program is the complexity of what you are shelling.
I kept it simple and was able to run this code without error after I substituted CMD for something simpler like ls so it could very well be that you may need to quote special characters. The first thing that stood out to me in your program is the complexity of what you are shelling.
And that does not address why the original code failed.
I think problem is in &&. if i just given "cat /tmp/ss.txt" then it is able to read and i am getting results back. but if i execute multiple commands by separating && then it is not working.
I am currently trying to write a script and I am not that great at wording it with taking in user input, it will do the following:
ask " Have you stopped instances? "
if instances are stopped, then I want it to change to the default java to 64 bits, and print the current version of java.... (1 Reply)
I have the following bash script lines in a file named test.sh.
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename... (3 Replies)
Hi all,
I am trying to install a .bin file for that it requires IBMJava2-AMD64-142-JRE-1.4.2-13.8.x86_64.rpm to be installed. I have installed this rpm but when i try to install .bin file, it complains that no JRE found. How to solve this. Thanks in advance!
#... (0 Replies)
Dear all experts,
Recently the daily batch run process (run using Java Runtime Execution)suddenly run slow. Our apps vendor came in and check and request to reboot the server. After rebooting of the server, the batch run back to normal.
May I know is periodically rebooting of pSeries server is a... (9 Replies)
Hi, community,
I am using Karmica koala 9.10 and I wish to add to Firefox the JRE plugin.
What I have to do?
The problem arises when I try to copy from the Downloads dir the file to
/usr/java that I created. I must have the root permissions, I think.
Please help. (1 Reply)
Runtime.getSystem.exec() waits for child process to complete .. I do not want to wait for the child process to complete ..what is the option which has to be used ? (2 Replies)