Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: JAVA: Run .exe in jpanel (NetBeans)

  1. #1
    Junior Member
    Join Date
    Sep 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA: Run .exe in jpanel (NetBeans)

    Hi developers,

    I have a code like this: try {

    System.out.println("Creating process..");
    Process p = Runtime.getRuntime().exec("C:\\Windows\\System32\\ notepad.exe");
    InputStream in = p.getInputStream();
    for (int i=0;i<in.available();i++)
    {
    System.out.println("df"+in.read());
    }

    Thread.sleep(10000);
    p.destroy();
    }catch (Exception ex)
    {
    ex.printStackTrace();
    }



    My purpose is to execute a .exe file in a jpanel.
    I have a jpanel and is there any feasible way to add .exe into the jpanel?

    Pls advise, thank you!


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    Post moved from Introductions section.

    is there any feasible way to add .exe into the jpanel?
    Can you explain what you want to happen? What happens when you execute the posted code?

    A method in a class that extends then JPanel class should be able to use one of the java classes and methods that will execute a .exe program.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Sep 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    Quote Originally Posted by Norm View Post
    Post moved from Introductions section.


    Can you explain what you want to happen? What happens when you execute the posted code?

    A method in a class that extends then JPanel class should be able to use one of the java classes and methods that will execute a .exe program.
    Hi, this is because I will create a unity3d which is the rendering of 3D motion and I wanted to integrate that interface into interface in java application.
    So the unity3d is built to .exe and so I want to run it from the java application (but the interfaces are all display in JPanel, that why I wanted my .exe to run in the jpanel)

    Hope this is clearer to you.

    Thank you!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    What problem are you having executing the .exe program?
    What happens when you execute the posted code? What do you want the program to do differently?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Sep 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    Quote Originally Posted by Norm View Post
    What problem are you having executing the .exe program?
    What happens when you execute the posted code? What do you want the program to do differently?
    Hi, I do not have any problem executing the open .exe code above.
    Just that I have a jpanel p and I wanted to run the .exe in jpanel so I tried something stupid like p.add(*the cmd to open .exe*);

    But turns out there is no suitable method for jpanel(process) found..

    So is there any other way? because my UI in java application is organised by jpanels. that why's I wanted to put .exe into jpanel..

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    I wanted to run the .exe in jpanel
    Any method in a class that extends the JPanel class can run an .exe file. I don't see what the problem is.
    When the .exe program executes it will be in its own OS process and open its own windows as it desires.
    Read the API doc for the Process class for more information.

    What do you mean by "run the .exe in jpanel"?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Sep 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    Quote Originally Posted by Norm View Post
    Any method in a class that extends the JPanel class can run an .exe file. I don't see what the problem is.
    When the .exe program executes it will be in its own OS process and open its own windows as it desires.
    Read the API doc for the Process class for more information.

    What do you mean by "run the .exe in jpanel"?

    Means like usually when I run the program .exe, it will open a window..
    But instead of open a new window, it will show in a JPanel to display.. Thank you

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA: Run .exe in jpanel (NetBeans)

    I don't know of any way to get the window of a .exe program to display as the contents of a JPanel.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Help with NetBeans App using JPanel/JFrame with JButton (if statements)
    By deanbyrne95 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 3rd, 2013, 07:48 PM
  2. Why it run in Netbeans(7,3,1) IDE but not with jar (in side dist folder)
    By simonongsk in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 23rd, 2013, 04:05 AM
  3. How to Add JPanel to JFrame during run-time
    By patelramanna in forum AWT / Java Swing
    Replies: 2
    Last Post: December 12th, 2012, 08:32 PM
  4. Calling exe files from Java
    By linuxrockers in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 26th, 2010, 04:20 AM