How to launch standard browser out of Java application?
Posted
by Peter
on Stack Overflow
See other posts from Stack Overflow
or by Peter
Published on 2010-04-12T19:09:35Z
Indexed on
2010/04/12
19:13 UTC
Read the original article
Hit count: 385
Hi there
how to I open a URL with the systems standard browser with Java?
I currently use this code for opening a specific URL (locally stored html file), which works fine when I run the application with my IDE (Eclipse), but after bundling the software, it doesn't work any more.
url = MainWindow.class.getResource("mySite.html");
helpMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
java.awt.Desktop.getDesktop().browse(url.toURI());
}
catch (URISyntaxException e1) {
e1.printStackTrace();
}
catch (IOException e1) {
e1.printStackTrace();
}
}
});
Any suggestsions? Thank you very much!
© Stack Overflow or respective owner