Create a brand new file known as Utility.java
and paste the next:
import javax.swing.*;
import java.internet.InetAddress;
import java.internet.UnknownHostException;
public class Utility {
public static void predominant(String...args) throws UnknownHostException {
JFrame body = new JFrame("Pattern App");
body.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
body.setSize(300,300);
String person = System.getProperty("person.title");
String host = InetAddress.getLocalHost().getHostName();
JTextArea txt = new JTextArea();
txt.setText(
"n" +
" Person: "+person+"n" +
" Host: "+host+"n"
);
body.getContentPane().add(txt);
body.setVisible(true);
}
}
Now open the terminal/command-line and kind:
java Utility.java
It will present a GUI utility that can have a textarea with two traces of textual content:
- Your logged-in username
- The machine’s hostname