Improved main method to run either the JFrame or the command line