A problem that occurs when you run this from a java GUI is it runs in the background.
So you cannot see the command prompt at all.
To get around this, you have to run the java.exe through "cmd.exe" AND "start".
I dont know why, but if you put "cmd /c start" infront it shows the command prompt as it runs.
However, the problem with "start" is that if there is a space in the path to the application
(which the path to the java exe usually have as it is in
C:\Program Files\Java\jre6\bin\java.exe or similar),
then start just fails with "cannot find c:\Program"
So you have to put quotes around C:\Program Files\Java\jre6\bin\java.exe
Now start complains about parameters that you pass to java.exe:
"The system cannot find the file -cp."
Escaping the space in "Program Files" with a backslash also does not work.
So the idea is to not use space.
Generate a temporary file with the bat extension and then put your command with spaces in there
and run the bat.
However, running a bat through start, does not exit when done,
so you have to put "exit" at the end of the batch file.
This still seems yucky.
So, looking for alternatives, I have found that using quote space quote in the space of "Program Files" actually works with start.
In the EXECUTE class above change the string builder appends to:
append( "cmd /C start \"Some title\" " ).
append( java.lang.System.getProperty( "java.home" ).replaceAll(" ", "\" \"") ).
append( java.io.File.separator ).
append( "bin" ).
append( java.io.File.separator ).
append( "java" ).
append( " " ).
append( new java.io.File( "." ).getAbsolutePath() ).
append( java.io.File.separator ).
append( CLASS_TO_BE_EXECUTED ).