how to open a webpage with java

Solutions on MaxInterview for how to open a webpage with java by the best coders in the world

showing results for - "how to open a webpage with java"
Éloïse
19 Nov 2017
1/**
2 * author Scratchy (Twitter @S_cratchy)
3 * Just import stuff
4 */
5import java.awt.Desktop;
6import java.io.IOException;
7import java.net.URI;
8import java.util.logging.Level;
9import java.util.logging.Logger;
10
11
12/**
13This you put in your button or whatever
14 */
15String url_open ="HTTPS://www.google.com";
16try {
17java.awt.Desktop.getDesktop().browse(java.net.URI.create(url_open));
18} catch (IOException ex) {
19Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
20}