Pages

Thursday, September 17, 2015

Shell Script : How to find jar or class file in ear/war file and update it ?


This shell script will find class inside the jar file . then update it automatically .


* Create shell script file and copy the code mention below

* Run the script like ./updatejar.sh  <jar name> <class toupdate>

* Update the location of jarcommand 
 from /home/oracle/dump/java/jdk1.6.0_65/bin/jar
to your location 





It required to update only one jar or class file in ear ,war or jar file , then below script can be used

............................................................................
if [ $# != 2 ]

 then

echo " format is ear class like"

echo "idcserver.jar DocServiceHandler.class"

  exit

fi


jarcommand=/home/oracle/dump/java/jdk1.6.0_65/bin/jar

earfile=$1
classfile=$2


echo " cksum  before update `cksum  $1`"
details=`$jarcommand -tvf $1 | grep $2 | awk '{print $8}'`

echo $details

install -D $2  $details

cp $1 $1_bak

$jarcommand -uvf $1 $details

echo " cksum after  update `cksum $1`"

........................................................................................


Sample output :
 ./shell.sh idcserver.jar DocFieldUtils.class
 cksum  before update 1875056577 8271840 idcserver.jar
intradoc/shared/DocFieldUtils.class
adding: intradoc/shared/DocFieldUtils.class(in = 3069) (out= 1716)(deflated 44%)
 cksum  after  update 1703931033 8315453 idcserver.jar


No comments:

Post a Comment