Java 如何在ear文件中更新jar文件
要更新添加一个类的jar文件,我可以使用它: jar-uvf 但是我需要更新ear文件中的jar文件,我尝试了下面的命令,但没有成功: jar-uvf NameOfEarfile.ear:FolderName/NameOfJar.jar路径/NameOfClass.classJava 如何在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服务器。然后使
有人能帮我吗?更好的方法是使用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