Title: Message
     o método exec() lança IOExeption e por isso deve estar em um bloco try...catch:
public Process exec(String command)
             throws IOException
Executes the specified string command in a separate process.

The command argument is parsed into tokens and then executed as a command in a separate process. The token parsing is done by a StringTokenizer created by the call:

 new StringTokenizer(command)
 
with no further modifications of the character categories. This method has exactly the same effect as exec(command, null).

Parameters:
command - a specified system command.
Returns:
a Process object for managing the subprocess.
Throws:
SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess.
IOException - if an I/O error occurs
 faça assim:
 
      try{
         Runtime.getRuntime().exec("calc.exe");
      }catch(java.io.IOException e){}
 
falou,
 
Pablo
-----Original Message-----
From: Monitoria [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 8 de January de 2003 4:53 PM
To: [EMAIL PROTECTED]
Subject: [java-list] Executar programa externo a partir do java.

Olá pessoal,
 
Não estou conseguindo rodar uma programa exter no a partir de uma aplicação java. Abaixo segue o trecho de código que estou usando mas está dando erro de compilação:
 
"Runtime.getRuntime().exec("calc.exe");"
 
O erro retornado é:
 
"C:\FSA\segundoc\AplicaBanco.java:214: unreported exception java.io.IOException; must be caught or declared to be thrown Runtime.getRuntime().exec("calc.exe");"
Gostaria de saber o que está errado, como se sigo da mesma maneia par fazer isso em um applet?
 
Obrigado.
 
Atenciosamente,
 Cristiano José da Silva
 
"A mente que se abre a uma nova idéia jamais volta ao seu tamanho original."
                                                                                               ( Albert Einstein)

Responder a