Another way to do it (from How to launch a file protocol URL with an anchor from Java? ):
Runtime.getRuntime().exec("cmd.exe start file:///C:/foo/bar.html#anchor")
Update:
Yet another link with this issue (using url.dll) shows the author reverting to trying an external program, in this case Quero: Runtime.getRuntime().exec("cmd.exe qlaunch.exe open=\"file:///c:/temp/test.html?p=1\"");
From what I can tell, this is a bug in Windows and/or Internet Explorer in particular. Firefox has other issues with the file://
protocol that you have to manually disable.
Update 2:
This is definitely either expected behavior or a bug in Windows itself. Using Desktop.browse
(which sends the URI clean to ShellExecute) or cmd.exe start
or Runtime.getRuntime().exec("rundll32 url.dll " + uri)
or even just opening a command prompt and typing the file://
URI itself just ends up doing this (which I found via Process Monitor):

Order of operations shown:
- (1st box) Thread Create = when I hit enter in the cmd window above
- Look for the file by traversing the directory tree (e.g. go into c:, go into temp)
- (2nd box) When that file is found, STOP looking (which means Windows parsed off the
#
and ?
characters)
- (3rd box) DONE looking (CloseFile on parent folder, followed by no more disk I/O)
- (4th box) Now that the file is found, look to see what .htm files are opened with (e.g. your browser)
- Oddly enough, later on it finds Chrome (default browser) but runs IE (?!) and then runs Chrome - this might be a big part of the problem.
Note that calling start iexplore file:///c:/temp/test.html#mark
does work because it's just passing the parameter without trying to do anything special.
Note that steps 2 and 3 violate Microsoft's own advice from 2006 (see here) but from what I've seen this behavior was introduced at the time that IE7 was released. My guess is that this fixed some bug or security flaw in Windows at the cost of being able to do this at all.
With some more research, it appears that file:
URIs in Windows have had a very sordid past
Oddly enough, a Microsoft article from 2010 shows file://host/path/file.txt?Query#fragment
as a valid URI in .Net...
I think you might be out of luck until someone finds a magical Registry setting - or you can manually call a browser (e.g. Runtime.getRuntime().exec(chromepath + "chrome.exe file:///c:/temp/test.html#jump")
or Runtime.getRuntime().exec(iepath + "iexplore.exe file:///c:/temp/test.html#jump")
)
Or, for fun: Runtime.getRuntime().exec("cmd.exe start iexplore " + myURL)