In our application, we are allowing users to open files and directories.
Java 6 provides us with...
java.awt.Desktop.getDesktop().open(file);
which works great. However, since we need to ensure Java 5 compatibility, we also implement a method of opening files by calling the start
command in cmd.exe
...
String command = "cmd.exe start ...";
Runtime.getRuntime().exec(command);
This is where the problem shows up. It seems that the start
command can only handle 8.3 file names, which means that any non-short (8.3) file/directory names cause the start
command to fail.
Is there an easy way to generate these short names? Or any other workarounds?