java application – dremi.INFO https://www.dremi.info Software Development, Digital Marketing and News Sun, 27 Mar 2011 05:30:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 https://www.dremi.info/wp-content/uploads/2020/12/cropped-icon-32x32.png java application – dremi.INFO https://www.dremi.info 32 32 Create a simple application to open an EXE file on the window with JAVA https://www.dremi.info/tutorials/java/create-a-simple-application-to-open-an-exe-file-on-the-window-with-java.html https://www.dremi.info/tutorials/java/create-a-simple-application-to-open-an-exe-file-on-the-window-with-java.html#comments Sun, 27 Mar 2011 05:30:00 +0000 https://www.dremi.info/?p=1267 […]]]> 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!

]]>
https://www.dremi.info/tutorials/java/create-a-simple-application-to-open-an-exe-file-on-the-window-with-java.html/feed 5