I am trying to open a static url from a web application when user clicks a button on a screen. Our application is deployed on a linux box and using the below program its trying to open a browser. 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.
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:
Runtime runtime = Runtime.getRuntime();
runtime.exec("/usr/bin/firefox -new-window " + url);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.