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!
Michael, a very interesting post thanks for writing it!
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
terima kasih info nya dan artikelnya
sangat membantu 🙂
okok, slamat belajar di blog sederhana ini 😀
gimana caranx edit foto aq ngk menger nih