Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open an HTML file in the default browser from a Java Swing application?

My Java Swing application generates an HTML file, and I want to open it with the default browser when it is generated and saved. How can I do this?

like image 917
kovike Avatar asked Feb 24 '10 01:02

kovike


People also ask

How to open HTML file in browser using Java?

Runtime rTime = Runtime. getRuntime(); String url = "D:/hi. html"; String browser = "C:/Program Files/Internet Explorer/iexplore.exe "; Process pc = rTime.


1 Answers

If you are using Java 6, use Desktop.open(). It allows you to open any file with the default application associated with its file type on the system.

like image 77
Chandra Sekar Avatar answered Oct 19 '22 02:10

Chandra Sekar