URL is the URL you want to display in your default web browser. For example, connect http://www.site.com/report.html to this input to display the HTML file report.html on the web server www.site.com in the browser. Our problem is to write a java program to open the input URL in the default browser of the Windows system. To open any URL, we use different java predefined files to operate our desktop.
Algorithm:
Desktop desk=Desktop.getDesktop();
desk.browse(new URI("http://xyz.com"));
// Java Program to Open Input URL in // System Default Browser in Windows import java.awt.Desktop; import java.io.*; import java.net.URI; class GFG { public static void main(String[] args) throws Exception { Desktop desk = Desktop.getDesktop(); // now we enter our URL that we want to open in our // default browser desk.browse(new URI("http://xyz.com")); } }
Output
(Our URL "http://xyz.com" will open in our desktop default browser)
Australia
UK
UAE
Singapore
Canada
New
Zealand
Malaysia
USA
India
South
Africa
Ireland
Saudi
Arab
Qatar
Kuwait
Hongkong
Copyright 2016-2023 www.programmingshark.com - All Rights Reserved.
Disclaimer : Any type of help and guidance service given by us is just for reference purpose. We never ask any of our clients to submit our solution guide as it is, anywhere.