I would like to add documentation to my project. By clicking on F1, I open the documentation in a certain place (for documentation I have 1 file(index.htm)). However, I can not open the URL with anchor. I have formed the correct URL, but .browse () open the document without anchor(at the beginning).
public void openHtmlDocument() throws IOException, URISyntaxException {
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
File file = new File(servletContext.getRealPath("/documentation/index.htm"));
URL url = new URL(file.toURI().toURL(), "#_Toc502051959");
Desktop.getDesktop().browse(url.toURI());
}
How can I fix this? The rest of other answers did not actual for me, because users use Windows or Linux. Formed URI:
file:/D:/app/wildfly-13.0.0.Final/standalone/tmp/vfs/deployment/deployment545477ea955f6f3d/mainUI-1.2.14.0.war-7f1f239336b4e258/documentation/index.htm#_Toc502051959
My browser URL after opening: