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?

Recommended Answers

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[] …
Jump to Post

All 2 Replies

Google Java ProcessBuilder for examples and tutorials

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();  
        }  
    }  
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.