Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2006

Tip: Looking for answers? Try searching our database.

java and tar command

Thread view: 
:-o - 23 Mar 2006 22:39 GMT
Thanks,

In java code, is there some way to untar (decompress) a tar file?

I thought Runtime.getRuntime().exec'ing on jar.exe executable with -xvf <jar
filename> might get it, but it won't.
Also tried renaming tar extension to jar and no luck.

I need to run this in java and windows O/S.

Frank
Gordon Beaton - 23 Mar 2006 22:49 GMT
> I thought Runtime.getRuntime().exec'ing on jar.exe executable with
> -xvf <jar filename> might get it, but it won't. Also tried renaming
> tar extension to jar and no luck.

So which do you mean: jar or tar?

Renaming files randomly isn't likely to help; use the right tool for
the job, i.e. tar with tarfiles and jar with jarfiles.

If you really mean tar you will need to get a copy of tar for your
platform, unless someone else suggests a different tool that can do
the job.

Yes you can do this with Runtime.exec(), but then there's the distinct
possibility you might be doing something wrong. One tip is to drop the
v (verbose) flag since that output isn't doing anything useful. In
fact it could very well be related to the problem if you aren't
handling the process' OutputStreams properly.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

:-o - 26 Mar 2006 00:24 GMT
Sorry for the time it took to reply.  Family issues...

I have a tar file lets call it group.tar containing 3 tar files.  I'd like to be
able decompress the 3 inner tar files in java

>> I thought Runtime.getRuntime().exec'ing on jar.exe executable with
>> -xvf <jar filename> might get it, but it won't. Also tried renaming
[quoted text clipped - 16 lines]
>
> /gordon
Chris Uppal - 26 Mar 2006 11:09 GMT
:-o wrote:

> I have a tar file lets call it group.tar containing 3 tar files.  I'd
> like to be able decompress the 3 inner tar files in java

TAR isn't a compressed format -- it's an archive format /only/.

Of course, the files /in/ the archive might be compressed, but tar neither
knows nor cares about that.  Or the archive file itself might have been
compressed (often, not not exclusively, with gzip to form a .tgz "tarball").
Some tar utilities include the ability to de/encompress the archive file
automatically too -- but that's just a (misguided IMO) convenience feature to
save typiing.

   -- chris
Chris Uppal - 24 Mar 2006 11:15 GMT
:-o wrote:

> In java code, is there some way to untar (decompress) a tar file?

Not as standard.

> I thought Runtime.getRuntime().exec'ing on jar.exe executable with -xvf
> <jar filename> might get it, but it won't.
> Also tried renaming tar extension to jar and no luck.

Tar and jar are completely different formats.

> I need to run this in java and windows O/S.

There is no standard external utility in Windows that will read tar files.  You
could find one, and include that in your distribution.

Alternatively, the tar format is not particularly complicated[*] so it should
be possible to write your own decoder.  More likely you will be able to find
one on the Net somewhere.  The only package that I know of (found with some
difficulty, since "tar" is not a good search term) is
   http://www.trustice.com/java/tar/
I can't comment on its quality since I've never used it.

([*] Though the GNU people, with typical arogance, unilaterally introduced a
bunch of incompatible extensions, which are messy to deal with.)

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.