java - open url in chrome browser only

后端 未结 3 883
长发绾君心
长发绾君心 2020-12-19 10:38

I have an url, I am trying to open that url in web view of JavaFX but the content was not compatible with web view. It\'s only compatible to the chrome and firefox. So I wou

相关标签:
3条回答
  • 2020-12-19 10:57
    Runtime.getRuntime().exec(new String[]{"cmd", "/c","start chrome http://goo.gl/EsomR0"});
    

    This worked for me.

    -- Edit: Only worked on Windows

    0 讨论(0)
  • 2020-12-19 11:00

    You'll need to use chrome.exe on Windows. On Linux this works for running Chromium:

    Runtime.getRuntime().exec(new String[] { "chromium-browser", "http://example.com/" });
    

    Obviously it's not going to work for Chrome (or Windows), but we're talking about the principle. Another possibility is that Chrome may not be installed. Try running it from the command line. If it doesn't work there, it's not going to work in Java. Another problem could be that you capitalized "Chrome".

    0 讨论(0)
  • 2020-12-19 11:04

    I have tried following for android to open URL only in chrome and it worked for me:

    "googlechrome://navigate?url=" + url
    
    0 讨论(0)
提交回复
热议问题