zecboy
#1
Preciso chamar um .Exe em Cs estou fazendo assim:
import java.io.IOException;
public class Teste {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
try {
//Process p = r.exec ("cmd.exe /c start C:\\NFe\\unfe.exe");
Runtime.getRuntime().exec("C:\\NFe\\unfe.exe");
System.out.println("Try");
// Runtime.getRuntime().exec("cmd.exe /c start C:\\NFe\\unfe.exe");
} catch (IOException iOException) {
{
iOException.printStackTrace();
System.out.println("Cath");
}
}
}
}
Só que da um erro ao executar o arquivo, alguém tem alguma solução?
zecboy
#2
[quote=zecboy]Preciso chamar um .Exe em Cs estou fazendo assim:
import java.io.IOException;
public class Teste {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
try {
//Process p = r.exec ("cmd.exe /c start C:\\NFe\\unfe.exe");
Runtime.getRuntime().exec("C:\\NFe\\unfe.exe");
System.out.println("Try");
// Runtime.getRuntime().exec("cmd.exe /c start C:\\NFe\\unfe.exe");
} catch (IOException iOException) {
{
iOException.printStackTrace();
System.out.println("Cath");
}
}
}
}
Só que da um erro ao executar o arquivo, alguém tem alguma solução?[/quote]
Então eu teria que conectar na pasta para poder executar, pois o .exe precisa de algumas dlls que estão n apas.
Existe uma versão de Runtime.exec ( http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html#exec(java.lang.String[],%20java.lang.String[],%20java.io.File) ) que aceita o diretório inicial do programa, para ele poder já iniciar no diretório correto. Leia a documentação.