0

Hello people of stackoverflow :)

Today i have come across a problem which i need some help fixing.

I want to get the contents of a folder from my computer then add that contents into a jar file replacing any existing files already in that jar file. I am attempting to do this from within a java program.

I already wrote a method that will extract the contents of the jar file but i came up that this will be a faster and much more efficient method for what i have to do.

Any help with this would be greatly appreciated.

user2826304
  • 97
  • 1
  • 2
  • 10
  • 2
    Try opening the jar-file with WinRar or 7Zip. – Birb Sep 28 '13 at 13:02
  • 1
    What are you trying to achieve? Create a normal executable jar? You don't need a method to extract the contents of a jar. Just extract the file with a decompressor. – mike Sep 28 '13 at 13:04
  • I am trying to edit an already executable jar with files from a folder on my computer, but i want to do this through a piece of code in my application. – user2826304 Sep 28 '13 at 13:06
  • Are you trying to [update the JAR containing the class file which you are currently running](http://stackoverflow.com/q/6477318/230513)? – trashgod Sep 28 '13 at 14:02
  • No i am trying to edit an already existing jar file by adding in file from a directory on my computer. In my actual application their will be an option to choose what directory you wish the files to be added from. – user2826304 Sep 28 '13 at 14:20
  • I still need help with this if anybody can help me, It will help me out a lot with my project. – user2826304 Sep 29 '13 at 02:03

2 Answers2

0

have you tried looking into the docs http://docs.oracle.com/javase/tutorial/deployment/jar/update.html ?

Balaji Krishnan
  • 1,007
  • 3
  • 12
  • 29
0

If you want to do it from a Java application, you can consider Runtime.getRuntime().exec("your command")

senseiwu
  • 5,001
  • 5
  • 26
  • 47