• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to create tar using Java in windows os

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI all,
I have to take some backup of some files from my application using java program. The final output should be in .tar format because this backed up data will be used in the application running in linux box and the linux box due to limited space does not have any other utilities like GZIP or unzip. Only the tar is supported. Hence i need to produce the back up data in tar format.
Please advice me how to do it in windows environment ?
Sample code will be really great help for me.

Thanks in advance.
Satya
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use cygwin to run *nix programs under Windows.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems like there are at least 3 approaches:

1. Call "tar" using one of the flavors of java.lang.Runtime.exec() . Note that this might not be portable. Joe Ess alluded how to get a "tar" that runs on windows
2. Find a tar library written in java and code against it. Here is something I found on Google search that alludes to such a library http://bugs.gentoo.org/show_bug.cgi?id=75343
3. Instear of tar, use jar for which java has built-in support. zip/unzip utilities are tiny in size in relation to the archives that you'll be making. This might be the path of least effort.

Which do you like best?
[ November 26, 2008: Message edited by: Sev Zaslavsky ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another Java tar library is Apache Commons Compress. It's currently available as source code only, but it works well.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or you can use the GZIPOutputStream class.
reply
    Bookmark Topic Watch Topic
  • New Topic