簡體   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