JDK 1.5 Live Code Examples

M

marcello

Hi my name is marcello,

I have this problem,
my application call a Runtime.exec() where the command is:

On Linux

"rm -f -r /usr/local/wa/etichette/etichetta0"

On Windows :-(

"del c:\\Programmi\\wa\\etichette\\etichetta0"

On linux is ok but in windows catch an exception
"can'Create a process"

Thank you for your help :)
 
S

Steve W. Jackson

marcello said:
:Hi my name is marcello,
:
:I have this problem,
:my application call a Runtime.exec() where the command is:
:
:On Linux
:
:"rm -f -r /usr/local/wa/etichette/etichetta0"
:
:On Windows :-(
:
:"del c:\\Programmi\\wa\\etichette\\etichetta0"
:
:On linux is ok but in windows catch an exception
:"can'Create a process"
:
:Thank you for your help :)

Interestingly enough, those two commands don't necessarily do the same
thing, even if your Windows version worked.

To fix that, you probably need to put "cmd /c" in front of the "del"
command since you want the command shell to execute the del command.

But the del command deletes a file. If that's a directory, it will
error. The Linux command rm when used with the -r switch will
recursively remove a directory and its contents. The -f switch
suppresses any errors or warnings (and could be combined to "rm -rf").

If in fact the item you're attempting to delete is a file and not a
directory, why not simply do it internally in Java? Create a
java.io.File object representing it and call its delete() method.

= Steve =
 

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
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top