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) {

How do I display message in browser status bar?

In this applet example you’ll see how to display a message in browser status bar. To make the example a bit more
interesting we’ll display the current time as the message. The time will be updated every on second during the lifetime
of the applet.

package org.kodejava.applet;

import java.applet.Applet;
import java.awt.Graphics;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TimeApplet extends Applet implements Runnable {
    private DateFormat formatter = null;
    private Thread t = null;

    public void init() {
        formatter = new SimpleDateFormat("hh:mm:ss");
        t = new Thread(this);

    public void start() {

    public void stop() {
        t = null;

    public void paint(Graphics g) {
        Date now = Calendar.getInstance().getTime();
        // Show the current time on the browser status bar

    public void run() {
        int delay = 1000;
        try {
            while (t == Thread.currentThread()) {
                // Repaint the applet every on second
        } catch (Exception e) {

Here is the html for our applet container.

<!DOCTYPE html>
<html lang="en">
    <title>Time Applet</title>