java and tar command

O

:-o

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
 
G

Gordon Beaton

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
 
C

Chris Uppal

:-o said:
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
 
O

:-o

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
 
C

Chris Uppal

:-o said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top