Java Program to Open Input URL in System Default Browser in Windows Last Updated : 19 Jan, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report URL is the URL you want to display in the default Web browser. For example, wire 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 Input URL in System Default Browser in Windows. To open any URL we use different predefine files of java to operate with our Desktop. java.awt.Desktop: We use java.awt.Desktop class because java.awt.Desktop allow us to interact with different capability of our Desktop. For Example Launching User default Browser, Launching user default mail Client etc.java.net.URI: java.net.URI is used to Represent User Resource Identifier reference. Algorithm: Firstly, we create an Object of our-defined class that we import by java.awt.Desktop.During the creation of an object, we use getDesktop() method that returns the Desktop instance of the current desktop context. On some platforms the Desktop API may not be supported, in that case we use isDesktopSupported() method to determine if the current desktop is supported. Desktop desk=Desktop.getDesktop();Then we use browse() method where we enter our URL that we want to open on our desktop by new URI(). desk.browse(new URI("http://xyz.com")); Java // 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) Comment More infoAdvertise with us Next Article Java AWT | Desktop Class S sambhavshrivastava20 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Practice Tags : Java Similar Reads Java Program to Get Connected to a Web Server In today's interconnected world, connecting to web servers is a fundamental skill for software developers. Whether you're building a web application that needs to fetch data from external sources, testing a web service, or even performing web scraping for research, knowing how to interact with web s 4 min read How to Convert a String to URL in Java? In Java, a string is a sequence of characters. A URL, which is short for Uniform Resource Locator, refers to a web resource that specifies its location on a computer network and provides the mechanism for retrieving it. To represent a URL in Java, we use the java.net.URL class. In this article, we w 2 min read Java AWT | Desktop Class The Desktop class is a part of Java AWT package. This class is used to launch associated applications registered on the native desktop to handle a URI or a file. Important Points About Desktop Class : It can open a default web browser showing a specific URI It can launch default mail client with opt 5 min read Java AWT | Desktop Class The Desktop class is a part of Java AWT package. This class is used to launch associated applications registered on the native desktop to handle a URI or a file. Important Points About Desktop Class : It can open a default web browser showing a specific URI It can launch default mail client with opt 5 min read How to Open a Browser in Headless Mode in Selenium using Java? Headless testing has become a significant trend in modern web automation, offering numerous advantages for developers and testers. In Selenium, running tests in headless mode allows browsers to operate without the graphical user interface (GUI). This article delves into the concept of headless brows 6 min read How to open browser window in incognito/private mode using selenium webdriver? Selenium WebDriver is one of the most used tools for browser automation for the purpose of testing web applications. This makes it possible to automate a browser through the use of a simple API via different programming languages such as Java, C#, Python, and so on.While testing, sometimes you may w 3 min read Like