TCLUG Development Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Linux/Java Question



Greet the sun all,

I have a Linux/Java question.  It involves the exec() method.

I instantiated a Runtime object using java.lang.Runtime.getRuntime(). I
am using the exec method to execute a statement at the command line.

//Gets a runtime environment for executing GUNZIP and TAR.
Runtime rt = java.lang.Runtime.getRuntime();

//Executes GUNZIP and TAR.
rt.exec("gunzip -c " + tarFilePath + "/" + tarFiles[i] + " | tar xvf
-");

The statement decompresses a TAR file using GUNZIP and then extracts the
member files from the TAR archive. When I type in the statement at the
command line, it works to unzip and extract my files. However, when I
run the application, the statement doesn't unzip or extract the files,
and it doesn't throw an error either. How can I unzip and extract the
files from a Java application?

Example Statement: gunzip -c
/home/phoekstra/content/tta/images/001_img.tar.gz | tar xvf -

Thank you,

-- 
Perry Hoekstra
E-Commerce Architect
Talent Software Services
dutchman@mn.uswest.net