Reputation: 323
I know that using process or processbuilder class in java I can start application.
On windows, all i need is to open a default browser with the url that I specify and get the returned url from the browser back to java program. Think like I am getting url to get access token from facebook. How can I do this?
Upvotes: 2
Views: 1798
Reputation: 51421
There is perhaps a very little known API called java.awt.Desktop that allows launching of default applications on many platforms. Using it to launch the default web browser with a URL is easy:
if ( Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported( Action.BROWSE ) ) {
URI google = new URI( "http://www.google.com" );
Desktop.getDesktop().browse( google );
}
Upvotes: 3
Reputation: 3470
If your aim is to get only the response of a specific URL there is no need to launch the browser, all you have to do is to use the httpclient library from apache, return the result and parse it accordingly.
Upvotes: 1