Last year I had to write a small piece of java code to launch another application using one of the available ports between certain range. I wrote the code and saved the command to launch the java class in batch file so that when the user double clicks it, java class will launch the application.
There is a small catch here. The cmd window does not pause irrespective of how the program runs. If the program runs successfully, then fine. But how will the user know in case of any exceptions? So we need to add one line in the batch script at the end to pause the cmd window in case of any exceptions so that the user will get the chance to see what the exception is. The following line is what needs to be added so that the cmd window pauses in case of exceptions:
IF %ERRORLEVEL% NEQ 0 pause