如何从java桌面应用程序代码中打开新的浏览器窗口?

时间:2022-11-21 07:37:09

I want to open new browser window from java desktop application. If browser is already open, then new browser window should open. Every time it should open a separate window.

我想从java桌面应用程序打开新的浏览器窗口。如果浏览器已打开,则应打开新的浏览器窗口。每次它应该打开一个单独的窗口。

2 个解决方案

#1


1  

If you are using windows, this should do the trick:

如果您正在使用Windows,这应该可以解决问题:

Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.google.com");

Hope it helps.

希望能帮助到你。

#2


2  

The builtin mechanism for "opening a browser" would be

用于“打开浏览器”的内置机制将是

Desktop.getDesktop().browse(new URI("http://your.link..."))

Starting a new window / process each time might only be possible if you know the browser being used and know of a parameter to pass to always create new window.

如果您知道正在使用的浏览器并且知道要传递的参数始终创建新窗口,则每次都可以启动新窗口/进程。

#1


1  

If you are using windows, this should do the trick:

如果您正在使用Windows,这应该可以解决问题:

Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler http://www.google.com");

Hope it helps.

希望能帮助到你。

#2


2  

The builtin mechanism for "opening a browser" would be

用于“打开浏览器”的内置机制将是

Desktop.getDesktop().browse(new URI("http://your.link..."))

Starting a new window / process each time might only be possible if you know the browser being used and know of a parameter to pass to always create new window.

如果您知道正在使用的浏览器并且知道要传递的参数始终创建新窗口,则每次都可以启动新窗口/进程。