I am trying to get a java gui to open a web page. So the gui runs some code that does things and then produces a html file. I then want this file to open in a web browser (p
Ya, But if you want to open the webpage in your default web browser by a java program then you can try using this code.
/// file OpenPageInDefaultBrowser.java
public class OpenPageInDefaultBrowser {
public static void main(String[] args) {
try {
//Set your page url in this string. For eg, I m using URL for Google Search engine
String url = "http://www.google.com";
java.awt.Desktop.getDesktop().browse(java.net.URI.create(url));
}
catch (java.io.IOException e) {
System.out.println(e.getMessage());
}
}
}
/// End of file