troubleshooting Question

automate find and replace inside jar on linux platform

Avatar of enthuguy
enthuguyFlag for Australia asked on
Linux* BashShell ScriptingJava
2 Comments1 Solution120 ViewsLast Modified:
Hi Experts

Would like to get your advise on what is the best way to automate replacing files inside jar files on Linux platform.

1. We will have a directory "fixes" with all the code fix files. E.g xml, .class, .properties
2. We will have another directory with jar files one or more files (where all the fixes will go in)
3. Need your help in writing a script.
      a. Each jar should be unjar/unzip to a tmp directory
      b. Go through each code fix file one by one inside "fixes" directory
      c. Search inside unjar tmp location and replace.
      d. Take next code fix file, search again inside the same unjar tmp location and replace. Basically to find/replace all code fix files.
      e. Once all done. jar the file and clear tmp
      f. Now unjar next jar file and repeat from a to e.

Interesting part is
1. single code fix could be in multiple jar files
2. multiple code fix could be in single jar as well.

will try to upload sample files
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros