Java program to open input URL in System Default Browser in Windows (input URL from command prompt)

Open URL in Default Browser in Java: This java program will read a URL through command line and open it into default system browser.

package com.includehelp;

import java.awt.Desktop;
import java.util.Scanner;

 Program to open input url in system Default browser 
 in windows (input url from command prompt)
 @author includehelp
public class UrlDefaultBrowser {
    public static void main(String[] args) {
            Scanner sc  =   new Scanner(;
            System.out.println("Enter url ( format  : ");
            String url =;
            Desktop.getDesktop().browse(new URL(url).toURI());
        catch(Exception E){
            System.err.println("Exp : "+E.getMessage());


Enter url ( format  :
(Now URL opened in your System Default Browser)

Java Most Popular & Searched Programs »

Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.