Search code examples
javaweb-applicationsbrowserpost-parameter

open browser from java program with post parameter prefilled


I have a java program, where i can open a Internet Explorer or Any Browser. using Runtime.getRuntime().exec(cmd);

But I want to open a browser from my java program mentioning url and post parameter.

First of all, is this possible? How can i achieve this?


Solution

  • You can appled the URL to the command line parameter for example in IE:

    C:\Windows\System32>"C:\Program Files (x86)\Internet Explorer\iexplore.exe" http://stackoverflow.com/
    

    Firefox:

    C:\Windows\System32>"C:\Program Files (x86)\Mozilla Firefox\firefox.exe" stackov
    erflow.com
    

    and Chrome:

    C:\Windows\System32>"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
    " stackoverflow.com
    

    Works on windows, you will need to replace C:\Windows\System32>"C:\Program Files (x86)\Google\Chrome\Application with the the location of the application in your environment