Executing a sh file from java program in foreground
My purpose is to restart my Java application from within the application.
For this I have created a Java program that runs a sh file. This sh file has the command to start the same java Program.
when i run the parent Java program it executes the sh file and runs the Java Program in it in background. I want this program to run in foreground since the program takes inputs from the user. How can i make the program run in foreground.
Following is the code i use to execute the sh file
Following is sh file
String LINUX_CLIENT_BATCH_FILE = "client.sh";
String command = "./" + LINUX_CLIENT_BATCH_FILE;
rm -rf sdt-socket-client.log*
for lib in `find -name \*.jar`
if [ $1 ]; then
java -XX:NewSize=128M -XX:MaxNewSize=128M -XX:SurvivorRatio=8 -Xms350M -Xmx350M -Xrs -cp $cp com.sdt.A.D 'conf/' "localhost" 4445 'db/' $1 $2 $3 & echo $! > /usr/local/srb/srb_java.pid
java -XX:NewSize=128M -XX:MaxNewSize=128M -XX:SurvivorRatio=8 -Xms350M -Xmx350M -Xrs -cp $cp com.sdt.A.D 'conf/' "localhost" 4445 'db/'