Thursday, January 17, 2013

Store certificate in key store

When it is using trusted certificate in JAVA, it needs to be stored in JAVA key store.

JAVA default key store is %JAVA_HOME/jre/lib/security/cacerts

Using following command you can create a specific key store.

keytool -keystore keystore_name -storepass changeit -file \export\home\root.cer -import -alias alias_name -trustcacerts

Then use the following JAVA code to use the created key store.

System.setProperty("", "./keystore_name ");
System.setProperty("", "changeit");
System.setProperty("", "JKS");

Wednesday, January 16, 2013

Restart JAVA Process in crontab

Following is a shell script which can be used for restart JAVA application. If Application active count is zero(0), then this script can be used to restart the process. This shell script can be called by a crontab.

cat /dev/null > nohup.out
PRGCOU=`ps -eaf|grep JAVAApp.jar |grep -v grep |wc -l`

if [ $PRGCOU -eq 0 ]
nohup java -Xms32m -Xmx64m -jar JAVAApp.jar &
sleep 3