繁体   English   中英

如何更新耳朵文件中的jar文件

[英]How to update jar file inside ear file

要更新添加一个类的jar文件,我可以使用它:jar -uvf

但是我需要更新一个耳朵文件中的一个jar文件,我尝试了以下命令,但它不起作用:jar -uvf NameOfEarfile.ear:FolderName / NameOfJar.jar path / NameOfClass.class

有人可以帮我吗?

更好的方法是使用7zip软件。

以下是更新ear / war / zip / jar文件的代码。 在执行以下代码之前,请先将文件转换为Unix格式。

将以下代码复制到TestUpdate.sh文件中,然后复制到UNIX服务器。 然后使用以下命令。 确保TestUpdate.sh,类文件(要在EAR / WAR / ZIP / jar中复制)和EAR / WAR / ZIP / jar文件都在同一目录中。

dos2unix TestUpdate.sh
. ./TestUpdate.sh FileNameWhichYouWantToUpdate # EAR/WAR/JAR/ZIP filename

#!/bin/bash

#LearName='TEST.ear'
LearName=$1
jar xf $LearName
for clas in *.class
do                    
  echo "Checking for $clas ..."
  for f in *.jar
    do
      result=$(jar tf $f | grep -w $clas)
      if [ -n "$result" ]; then
        echo "$f contains $result"

        Lp="${#clas}";
        Lr="${#result}";
        count=$((Lr-Lp));
        #echo $count
        dirC=${result:0:$count};
        echo "Directory $dirC"
        echo $dirC
        mkdir -p $dirC;
        echo "Copying $clas $dirC"
        cp $clas $dirC;
        echo "updating $f ..."
        jar ufv $f $result;
        file_write "updating $f ..."
        echo "Updating $LearName ..."

        jar ufv $LearName $f;
        echo "-----------------------------------------------"

        break
      fi                                             
    done
done    
rm -f *.jar ---- comment this line if your input file is .jar. If your input file is EAR/WAR/ZIP file then NO need to comment this line
rm -r *.war
rm -r META-INF
rm -f *.tmp
rm -r com

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM