olyanren
olyanren

Reputation: 1458

Sending commands to browser

Hi I want to send url links from a Java application to a browser in Windows 7. How can I do this ?

Upvotes: 1

Views: 1052

Answers (2)

Andy White
Andy White

Reputation: 88345

If you want to just launch a browser to a certain URL, I'd recommend just using the Java APIs for launching a new process, and use the Windows start command.

Try opening a cmd.exe and running start http://google.com - you basically would just do that from your Java app using the process APIs, which you should be able to find a good tutorial on, if needed.

If you are asking about manipulating an existing browser window from another application, then your answer is going to be much more complicated.

Upvotes: 0

user142162
user142162

Reputation:

If by "send url links" you mean open a URL in a browser, this should work for you:

import java.awt.Desktop;
import java.net.URI;

// ...

if(Desktop.isDesktopSupported())
{
    Desktop.getDesktop().browse(new URI("http://www.example.com"));
}

Upvotes: 5

Related Questions