aspose file tools*
The moose likes I/O and Streams and the fly likes How to create tar using Java in windows os Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to create tar using Java in windows os" Watch "How to create tar using Java in windows os" New topic
Author

How to create tar using Java in windows os

satya sahu
Ranch Hand

Joined: Mar 26, 2003
Posts: 97
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
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

I use cygwin to run *nix programs under Windows.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sev Zaslavsky
Greenhorn

Joined: Nov 19, 2008
Posts: 7
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 ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Another Java tar library is Apache Commons Compress. It's currently available as source code only, but it works well.


Ping & DNS - updated with new look and Ping home screen widget
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Or you can use the GZIPOutputStream class.


Regards, Rene Larsen
Dropbox Invite
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to create tar using Java in windows os
 
Similar Threads
Postgres mirating data from 7.2.2 linux to 8.1.3 Windows
Number Format problem
JDK, path problem in Linux
Rigistry
Tar Command - Compress empty directories