How do I launch user-default web browser?

The code below show you how to browse a website using the user’s default web browser. To get the default web browser you can use the Desktop class browse(URI uri) method call.

package org.kodejava.awt;

import java.awt.Desktop;

public class RunningDefaultBrowser {
    public static void main(String[] args) {
        URI uri = URI.create("");
        try {
            // Get Desktop instance of the current browser context. An 
            // UnsupportedOperationException will be thrown if the 
            // platform doesn't support Desktop API. 
            Desktop desktop = Desktop.getDesktop();

            // Browse the uri using user's default web browser.
        } catch (IOException e) {

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.