In my JavaFX application, at a specific page I have to initialize (when loading the page) some devices such as iris scanner, fingerprint scanner, cameras etc. Before leaving the page/controller it is necessary to deinitialize the devices. There are two buttons in that page. If the user leaves this page by clicking one of these two buttons I can easily deinitialize them. But if the user leaves the page by clicking any menu/sub menu (there are more than 30 menu and sub menu in this application), how can I deinitialize these devices?
There is no destructor in java and I also tried using finalize
but nothing comes out.