2
I’m developing a java application for a college job and have a help section for the user where I open a page html
in the browser, or at least should open in this.
The issue is that if files with extension .html
were by default of the system to be opened by a browser, all right it will be opened by the browser, but if this extension is by default linked to, for example, a text editor it will open in the text editor revealing the code.
I wonder if there is a java mode of a document html
only be opened by the browser. The code I use is the below:
Desktop desktop = null;
desktop = Desktop.getDesktop();
URI url = null;
File file = new File("src/ajuda/index.html");
try {
url = new URI(file.toURI().toString());
desktop.browse(url);
} catch (URISyntaxException | IOException ex) {
Logger.getLogger(Teste.class.getName()).log(Level.SEVERE, null, ex);
}
And in case you would assume that the computer has a default program? type everyone has IE? in this case you could use Runtime.getRuntime(). exec(""C: Program Files Internet Explorer iexplore.exe" www.google.com");
– SneepS NinjA