Issue
I have a directory, update, with the same structure as a JAR file Application.jar. Now I want to (programmatically) replace all files in Application.jar with the files in the update folder. Lets say I have the following structure for both directory and jar file:
Application.jar / update
- TestDir
- text2.txt
- text1.txt
When using jar uf Application.jar update/TestDir/text2.txt
it creates a new directory in Application.jar - update - and it's going to be added all from there, even worse when using absolute paths (Creating the whole C:\ structure inside the jar file). How can I preserve the structure, is there some way to mark pathToUpdate\update as a root? I know there's the -C parameter, but I don't understand it.
Solution
You have two options.
First change the working directory to
update
so that the relative path to the 'update' file matches what you want in the jar:cd update jar uf ../Application.jar TestDir/text2.txt
use the -C option:
jar uf Application.jar -C update TestDir/text2.txt
It's possible the -C option requires that you do: jar Application.jar -C update update/TestDir/text2.txt
.
In general, I advise the first option; the second gets tricky once you start using e.g. *
and the like.
Answered By - rzwitserloot
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.