I am using a java application which opens a scratch file during run time. The scratch file communicates with the arduino board and gives the output. once the communication starts i am unable to use my User interface in java which has a close button instead i tried closing my entire application using end task in task manager. Can you please tell me as how to release the memory associated with the files. I used process. destroy and system.exit(0) but did not work.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
if("Disconnect".equals(jButton1.getText()))
{
System.exit(0);
}
jButton1.setText("Disconnect");
if(jComboBox2.getSelectedItem()==null)
{
System.out.println("Select one port");
}
else
{ Runtime r = Runtime.getRuntime();
try {
this.hide();
//p = r.exec("C:\\Program Files\\Scratch 2\\Scratch 2.exe C:\\Users\\Admin\\Desktop\\fwdbckpwm12.sb2");
p = Runtime.getRuntime().exec("C:\\Program Files\\Scratch 2\\Scratch 2.exe C:\\Users\\Admin\\Desktop\\scratch files new.sb2");
//p.destroy();
//r.exec("C:\\Windows\\notepad.exe C:\\Windows\\ss.txt");
A4S a4sObj = new A4S(new String[]{jComboBox2.getSelectedItem().toString()}); //defaultline
// A4S a4sObj = new A4S(new String[]{"COM16"}); //addedline
r.gc();
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
} catch (IOException ex) {
Logger.getLogger(serialportselection.class.getName()).log(Level.SEVERE, null, ex);
}
finally{
p.destroy();
System.gc();
}
}
}