Executing a sh file from java program in foreground
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mukti_furtado
Posted On:   Friday, July 3, 2009 11:53 AM

Hi 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 String LINUX_CLIENT_BATCH_FILE = "client.sh"; String command = "./" + LINUX_CLIENT_BATCH_FILE; Process theProcess=Runtime.getRuntime().exec(command);    More>>

Hi

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


			

String LINUX_CLIENT_BATCH_FILE = "client.sh";
String command = "./" + LINUX_CLIENT_BATCH_FILE;
Process theProcess=Runtime.getRuntime().exec(command);
System.exit(0);




Following is sh file


			

#!/bin/bash -e

rm -rf sdt-socket-client.log*
cp=".:conf:"

for lib in `find -name *.jar`
do
cp="$cp:$lib"
done
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
else
java -XX:NewSize=128M -XX:MaxNewSize=128M -XX:SurvivorRatio=8 -Xms350M -Xmx350M -Xrs -cp $cp com.sdt.A.D 'conf/' "localhost" 4445 'db/'
fi




Thanks    <<Less
About | Sitemap | Contact