How To Update Java Se Development Kit 8

So my question is, Is it possible to automatically register the iupdater when a revit document is opened and unregister when the document is closed?, and if so, How can I fix my code in order to get that result?