2

I have Jar file which includes besides classes - folder with files. When i run a jar file on the other machine - the aim is to copy files from jar to some folder in that machine. Structure of jar:

/somepackage/
/MyFolder/

in code i do something like this:

copyDirectory("MyFolder", System.getProperty("user.home") + "\\myFolder");

it works only when i start program, but not outside jar.

Please help me to do it.

gigadot
  • 8,879
  • 7
  • 35
  • 51
golgofa
  • 103
  • 2
  • 11
  • 2
    Duplicate: http://stackoverflow.com/questions/1386809/copy-a-directory-from-a-jar-file? – eboix Dec 17 '11 at 01:52

1 Answers1

0

You could either manually copy the data out, or, if the data is read-only, just access it directly when needed (simplifying your runtime requirements).

In either case, you'd need to read the contents in the jar file: How do I read a resource file from a Java jar file?

If you really prefer having things in a local directory, you will need to iterate over all the files you care to have moved out and place them on the disk yourself.

Community
  • 1
  • 1
sirbrialliance
  • 3,612
  • 1
  • 25
  • 15