开发者

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 a开发者_运维知识库nd saved. How can I do this?


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.


If you're not using Java 6 (or not sure your users will) - you can use Bare Bones Browser Launcher to launch the default browser. It uses Java 6 Desktop.open() if available, and falls back to platform specific approaches if it's not.


Check this page, this can give you a much more detailed usage of the Desktop API.


You can try this:

Runtime.getRuntime().exec("hh.exe index.chm");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜