Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在ear文件中更新jar文件_Java_Jar_Ear - Fatal编程技术网

Java 如何在ear文件中更新jar文件

Java 如何在ear文件中更新jar文件,java,jar,ear,Java,Jar,Ear,要更新添加一个类的jar文件,我可以使用它: jar-uvf 但是我需要更新ear文件中的jar文件,我尝试了下面的命令,但没有成功: jar-uvf NameOfEarfile.ear:FolderName/NameOfJar.jar路径/NameOfClass.class 有人能帮我吗?更好的方法是使用7zip软件。下面是更新ear/war/zip/jar文件的代码。在执行以下代码之前,首先将文件转换为unix格式 复制TestUpdate.sh文件中的以下代码并复制到unix服务器。然后使

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

但是我需要更新ear文件中的jar文件,我尝试了下面的命令,但没有成功: jar-uvf NameOfEarfile.ear:FolderName/NameOfJar.jar路径/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


最好重新打包EAR。我需要在一台unix服务器上执行此操作,并且在测试某些修复程序时只添加一个类。我需要在一台unix服务器上执行此操作,并且在测试某些修复程序时只添加一个类。
#!/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