I have a java program that is quite large, and we want to make it so that the user can exit the application and log in as another user. To do this, we would like to close the application and restart it so that it presents the user with a login dialog. The problem is that the application is quite large and poorly written. It has many static variables that contain some status information. Ideally, I would like to rewrite the application in order to cope with a situation where all of them can be cleaned up, but in reality we should provide this functionality as soon as possible.
What I thought would be easiest to just stop the application and start a new vm. However, it is surprisingly difficult to stop and apply the application and run the same application, closing the current one. Does anyone have experience with this?
EDIT: we continue to use Runtime.exec to call the same application again, but exec () wants to block, so we need to jump over the hoops to make it work on every platform (Windows, Mac, Linux). I would prefer a platform-independent way of doing this.
source
share