Msdos en java

Fermé
genie-netcom Messages postés 86 Date d'inscription jeudi 5 février 2009 Statut Membre Dernière intervention 13 juin 2011 - 24 nov. 2009 à 11:37
genie-netcom Messages postés 86 Date d'inscription jeudi 5 février 2009 Statut Membre Dernière intervention 13 juin 2011 - 24 nov. 2009 à 11:48
Bonjour à tous ,je veux lancer une commande cmd par un code java.le cose est le suivant:
import java.io.IOException;

public class msdos{
public msdos() {
}
public void delet (String path) throws IOException
{

String cmd = ("del "+path);
Runtime dos = Runtime.getRuntime();
dos.exec(cmd);
return;
//Thread.currentThread().g

}

public static void main(String[] args) throws IOException {
msdos ms = new msdos();
ms.delet("C:\\nn.txt");

}
}


il m'apparait les exeptions suivants je ne sais pas quel est l'erreur:


Exception in thread "main" java.io.IOException: Cannot run program "del": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at msdos.delet(msdos.java:12)
at msdos.main(msdos.java:20)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
A voir également:

1 réponse

genie-netcom Messages postés 86 Date d'inscription jeudi 5 février 2009 Statut Membre Dernière intervention 13 juin 2011 4
24 nov. 2009 à 11:48
S'il vous plait si quelqu'un sait comment je peux résoudre ceci m'aide, ,c'est très urgent je doit finir ceci aujourd'hui.
0