From a Java program, I need to launch the default browser on a local HTML file, pointed to an anchor inside the file. In Java SE 6, the java.awt.Desktop.browse method will
I just solved this another way, because no amount of quoting or spaces in any of these examples worked for me.
1 Detect if the file URI has a anchor or query string
2 If so, create a temp file File tmpfile = File.createTempFile("apphelp", ".html")
with a meta-redirect to the actual file URI I desire:
3 Execute the local rundll command using new temporary URI:
Runtime.getRuntime().exec(
"rundll32 url.dll,FileProtocolHandler \""
+tmpfile.toURI().toString()+ "\"");
I hope this works for you!