CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 1999
    Location
    California
    Posts
    264

    How can I run an .exe file in java?

    How can I run an .exe file in java?

    thank you!

    Best Regards,

    Kevin Shen
    Best Regards,

    Kevin Shen

  2. #2
    Join Date
    May 2000
    Location
    Indore (MP) INDIA.
    Posts
    356

    Re: How can I run an .exe file in java?

    Hi !
    You should you the Runtime and Process classes to Perform this. Below is a small Program, that will Illustrate this for you.



    /** RunFromJava.java : Demonstrates, How to Execute a Program from within Java */

    import java.lang.* ;

    public class RunFromJava
    {
    public static void main(String[] args)
    {
    Runtime r = Runtime.getRuntime();
    Process p = null;
    try
    {
    p=r.exec("Freecell"); // Starts the "Free Cell" Game
    p.waitFor();
    }
    catch (Exception e)
    {
    System.out.println("Error executing C" + e.toString());
    }
    }
    }




    Hope this helps.
    Enjoy Java.




    -Vipul Pathak.
    Pathak Developers Pvt. Ltd.
    Indore, (MP) INDIA.


    PS: If this helps you then Rate it, so let me know How much is this helpful to you.
    (*Vipul)() ;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured