0

I have jar demo1.jar . I want to replace one .class file [at com/example/demo2/ location] using java program .

path is like demo1.jar/BOOT-INF/classes/com/example/demo2/.

Holger
  • 285,553
  • 42
  • 434
  • 765
Ganesh Java
  • 37
  • 2
  • 9
  • `ZipFile` may help you as JARs are ZIPs. – dan1st Sep 09 '21 at 12:07
  • No ,Programmatically I want to do this . Using Java code . – Ganesh Java Sep 09 '21 at 12:11
  • Does using java jar considered java code ? :) Please see https://stackoverflow.com/questions/1667153/updating-class-file-in-jar – JCompetence Sep 09 '21 at 12:20
  • 1
    `ZipFile` is a java class that can be used for manipulating zip files. – dan1st Sep 09 '21 at 12:29
  • Not Working . Thanks dan1st and Susan for reply . Susan I have checked that post and that is not working in my case. I simply replace the .class file in jar at path is like demo1.jar/BOOT-INF/classes/com/example/demo2/. – Ganesh Java Sep 09 '21 at 12:33
  • The duplink has code to do this kind of thing. But note that you won't be able to reliably update a JAR that is on a running application's classpath. You will either get file lock errors, or unpredictable behavior for the running app. – Stephen C Sep 09 '21 at 12:38
  • Hi Stephen , Actually I want replace the .class file of jar in one folder using command line or java code . Could you please help me with any link or command if you know. Thanks in advanced. – Ganesh Java Sep 09 '21 at 13:06

0 Answers0