3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by DavidKroukamp
Featured Replies
  • [QUOTE=shotokanpoloto;1745409]I want to run an exe file in my project. I mean when I run my codes,a specific executable file run. How can I do that?[/QUOTE] you could also look at using a Runtime class of java:[code]import java.io.*; public class TestExec { public static void main(String[] args) { try { … Read More

1

I want to run an exe file in my project.
I mean when I run my codes,a specific executable file run.
How can I do that?

you could also look at using a Runtime class of java:

import java.io.*;  
public class TestExec {  
    public static void main(String[] args) {  
        try {  
            Process p = Runtime.getRuntime().exec("cmd echo Hello World");  //calls cmd.exe and prints hello world to console
            BufferedReader in = new BufferedReader(  
                                new InputStreamReader(p.getInputStream()));  
            String line = null;  
            while ((line = in.readLine()) != null) {  
                System.out.println(line);  
            }  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  
    }  
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.