Skillzone Skillzone - 1 year ago 99
Java Question

Java URL open and Close after random time

I need code that will open url and close it after some random time(3-10minutes)

Something like:

Desktop d = Desktop.getDesktop();
d.browse(new URI(""));
d.destroy(); //error there is no destroy function here

any ideas?

Answer Source

I looked into this some more, the Desktop class does not have a close() feature to it.

If you want to launch another program via Java you should use the Process class. Doing something similar to this:

public class Process {
    public static void main(String[] args) {
        try {
            Runtime runTime = Runtime.getRuntime();
            Process process = runTime.exec("notepad");
            try {
            } catch (InterruptedException e) {
        } catch (IOException e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download