如何在不重新打包整个jar的情况下更新jar中的一个文件? [英] How do I update one file in a jar without repackaging the whole jar?
问题描述
我有一个名为myfile.jar的.jar文件。在这个jar文件里面是一个名为images的文件夹。在这个名为images的文件夹中,我有一个名为hi.png的图像。我想用该图像的新版本更新该图像,也称为hi.png。我不想从单个jar文件中提取所有文件然后重新打包它们,我只是想更新图像。所以,我像往常一样去命令行,键入几行代码,然后我执行以下命令:
I have a .jar file called myfile.jar. Inside this jar file is a folder called images. Inside this folder called images, I have an image called hi.png. I want to update that image with a new version of that image, which is also called hi.png. I do not want to extract all of the files from the single jar file and then repackage them, I just want to update the image. So, I go to command line as usual, type a few lines of code, and then I do this command:
jar uf myfile.jar -C images hi.png
我希望用这个命令做的是取代老hi.png与新的hi.png。但是,它给了我这个错误:
What I hoped to do with that command was to replace the old hi.png with the new hi.png. But, it gives me this error:
images\hi.png : no such file or directory
我该怎么做才能解决这个问题?
What do I do to fix this?
额外信息:我不能使用类似WinRAR的东西,我必须使用命令行执行此操作。
Extra info: I can not use something like WinRAR, I have to do this with command line.
推荐答案
-C
正在更改本地目录,正在寻找那里有 hi.png
。它不能控制你将它注入JAR文件的位置。
-C
is changing the local directory, and is looking for hi.png
there. It's not controlling where you're trying to inject it into the JAR file.
我会尝试制作一个名为 images $ c的新目录$ c>,将你的本地
hi.png
移动到那里,使 images
当前工作目录的子目录,然后运行这个:
I would try making a new directory called images
, moving your local hi.png
into that, making images
a child directory of your current working directory, then just run this:
jar uf myfile.jar images\hi.png
这篇关于如何在不重新打包整个jar的情况下更新jar中的一个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!