B4J Question Java(TM) Platform SE binary - stop automatically

Orejana

Member
Hello everyone,
I've developed a UI-program which calls the Mainform_Closed sub on clicking the X. It then kills the MQTT-connection and saves my collected data. So far, so good.
But if I start it in Release mode (or use the jar-file to start it), the process Java(TM) Platform SE binary keeps running, the only way to kill it I can find is by using the task manager and do it manually. (If I re-run my code in Debug mode it tells me it cannot start because my jar-file is being used by another process)
Is there any way to kill that process automatically on closing the mainform?

Here's the code:
B4X:
Sub MainForm_Closed 'Methode, die beim Schließen des Applikationsfensters aufgerufen wird.
   mqtt.Close 'MQTT-Verbindung wird beendet
   Log("mqtt closed")
   SaveFiles(table_max,"temp_max.csv",temp_max,True) 'Alle Werte aus den drei Listen werden in je einer CSV-Datei gespeichert.
   SaveFiles(table_min,"temp_min.csv",temp_min,False) 'Dabei werden evtl. bereits bestehende Werte überschrieben.
   SaveFiles(table_moist,"moisture.csv",moist_max,True)
   Log("gespeichert")
End Sub
 

Orejana

Member
Okay, I'll try to rephrase ;-)
I wrote a program with a UI. I end it by clicking the X of the form. This triggers the MainForm_Closed sub which in turn saves my data and ends the mqtt-connection. My MainForm_Closed code is above. This all works fine.
But clicking the X does not end the process Java(TM) Platform SE binary, which keeps on running in the background (multiple times, if I re-start the jar-file several times). I want this process to end automatically when I click the X. So far, I can only end it by going to the task manager and end the process manually.

I hope this makes it clearer?

EDIT: Here's a screenshot of my task manager after I ran my jar-file three times and ended it each by clicking the X.
dPDSSp
 

Attachments

  • Unbenannt.PNG
    Unbenannt.PNG
    34 KB · Views: 215
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It is clear. What is your program doing? Are you running a Mqtt broker?

Are you using jSystemTray library?

You can always kill the process by calling ExitApplication, however it is better to find out why the process never quits. If it is a small project you can upload it will be easier to help you.
 
Upvote 0

Orejana

Member
It is clear. What is your program doing? Are you running a Mqtt broker?

Are you using jSystemTray library?

You can always kill the process by calling ExitApplication, however it is better to find out why the process never quits. If it is a small project you can upload it will be easier to help you.

Calling ExitApplication in my MainForm_Closed is working, thanks for that tip! I think I'll leave it at that as I have to hand in my code at the end of the week as part of my bachelors thesis. Thank you for your help! :)
 
Upvote 0
Top