[英]How do I open a URL on the client machine using java
I am trying to open a static url from a web application when user clicks a button on a screen.当用户单击屏幕上的按钮时,我试图从 Web 应用程序打开静态 url。 Our application is deployed on a linux box and using the below program its trying to open a browser.
我们的应用程序部署在 linux 机器上,并使用以下程序尝试打开浏览器。 Can you please advise how I can get it to to open it on the client instead ?
你能告诉我如何让它在客户端上打开它吗?
All our users access this application from windows.我们所有的用户都从 Windows 访问这个应用程序。
try {
Desktop desktop = java.awt.Desktop.getDesktop();
URI oURL = new URI("http://www.google.com");
desktop.browse(oURL);
} catch (Exception e) {
e.printStackTrace();
}
I'm 99% sure above solution works only for windows, for unix I believe you should try something like this:我 99% 确定上述解决方案仅适用于 Windows,对于 unix 我相信你应该尝试这样的事情:
Runtime runtime = Runtime.getRuntime();
runtime.exec("/usr/bin/firefox -new-window " + url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.