Create a simple application to open an EXE file on the window with JAVA

March 27th, 2011 by dr.emi

Create a simple application to open an EXE file on the window with JAVA

We will learn about how to open EXE file with JAVA. We use netbeans as IDE. So, please create new JAVA Application project. And a small form.

 

Step #1 Create few of label, combobox, and button from tool bar

I use few list item of combobox: Notepad, Window Explorer, Firefox, and Kalkulator as Target EXE

Step #2 Right click on Button to add action performed

Step #3 Use condition to select exe target

String target;
        String newTarget = null;
        target=(String) jComboBox1.getSelectedItem();
        if(target.equals("Notepad"))
        {
            newTarget = "C:\\Windows\\notepad.exe";
            jLabel3.setText(target + " EXECUTED!!");
        }
        else if(target.equals("Window Explorer"))
        {
            newTarget = "C:\\Windows\\explorer.exe";
            jLabel3.setText(target + " EXECUTED!!");
        }
        else if(target.equals("Firefox"))
        {
            newTarget = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
            jLabel3.setText(target + " EXECUTED!!");
        }
        else if(target.equals("Kalkulator"))
        {
            newTarget = "C:\\Windows\\System32\\calc.exe";
            jLabel3.setText(target + " EXECUTED!!");
        }
        else
        {
            jLabel3.setText("Silahkan Pilih Salah Satu TARGET EXE");
        }

        try
        {
            Process p = Runtime.getRuntime().exec(newTarget);
            p.waitFor();
            System.out.println(p.exitValue());
        }
        catch (Exception err)
        {
            err.printStackTrace();
        }

Step #4 Let’s RUN your application [F6]

That’s it!

Popularity: 34% [?]

You may also like

  • No Related Post

Download Unavailable Demo Unavailable
Bookmark Subscribe
Hello my fox! Glad to see you today!

If you love my tutorial, please chose any action from the left button.

7 Comments

Registry Cleaner Said:  

Michael, a very interesting post thanks for writing it!

csabi Said:  

Hi! I just love your tutorial! Congratulations!
I`we just opened a tutorials indexing website and I would like to ask you to submit your tutorials, it will bring you some extra traffic
Please give a chance for my website: http://www.tutorialswindow.com

Please let me know about your decision: info@tutorialswindow.com

Thanks!

Oh and we also award our users with gift points that can be used to buy ads in our sidebar

Tutorial Photoshop Said:  

terima kasih info nya dan artikelnya

sangat membantu :)

dr.emi Said:  

okok, slamat belajar di blog sederhana ini :D

elzi ati Said:  

gimana caranx edit foto aq ngk menger nih

dr.emi Said:  

@elzi ati
pertanyaan nya ga nyambung dengan topik posting :) silahkan gabung di forum, dan cari topik untuk pertanyaan yang cocok :)

http://www.dremi.info/forum

Deny Apriliansyah Said:  

pake percabangan switch kayaknya agar lebih tepat kalo untuk para newbie seperti saya. Kalo percabangan dengan menggunakan IF ELSE terlalu ribet bagi saya.

Hi.. ! Wanna say anything about my tutorial ?
Just say it with fill the comment form.
Comment Form
 

 
 
 
 
 
Category
stack

Switch to our mobile site