Added a try catch so make sure the server is closed properly and the JFrame is disposed if an exception is thrown