Chamar Executavel em CS

2 respostas
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?

2 Respostas

zecboy

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?

Então eu teria que conectar na pasta para poder executar, pois o .exe precisa de algumas dlls que estão n apas.

T

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.

Criado 12 de agosto de 2009
Ultima resposta 12 de ago. de 2009
Respostas 2
Participantes 2