Directly paste the code: Method 1: 1 runtime.getruntime(cmd.exe c ("rundll32 url. dll, FileProtocolHandler http://www.baidu.com "); Method 2: 1 // determine whether the current system supports Java AWT Desktop extension 2 if (java. awt. desktop. isDesktopSupported () {3 try {4 // create a URI instance. Note that it is not URL 5 java.net. URI uri = java.net. URI. create ("http://www.baidu.com"); 6 // get the current system desktop extension 7 java. awt. desktop dp = java. awt. desktop. getDesktop (); 8 // determine whether the system desktop supports the function to be executed 9 if (dp. isSupported (java. awt. desktop. action. BROWSE) {10 // obtain the default browser of the system to open the link 11 dp. browse (uri); 12} 13} catch (java. lang. nullPointerException e) {14 // If the uri is null, an exception is thrown. 15} catch (java. io. IOException e) {16 // The default browser of the system cannot be obtained. 17} 18}