Question: When I run the script, the browser proceeds to perpetually open new tabs until I end the process in the task manager. Shouldn't this loop only open the browser once? Even if you ignore the while loop and only focus on the browser request I get the same behavior. Does this have to do with the try/catch? What's going wrong here?

```
Desktop d = Desktop.getDesktop();       

Boolean doOnce = false;

while (doOnce == false) {
    try {
        d.browse(new URI("http://localhost"));
        doOnce = true;
    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

```

Answer: 
If you want to execute the try/catch block only once in `while` you should put the `doOnce` in your finally block :

```
try 
{
    d.browse(...);
} catch (URISyntaxException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}finally{
doOnce = true;
}

```

but if you want to exit from `while` when an exception occurred you should put it in catch block :

```
try 
{
    d.browse(...);
} catch (URISyntaxException e) {
     doOnce = true;
    // TODO Auto-generated catch block
    e.printStackTrace();
}

```
```
try 
{
    d.browse(...);
    doOnce = true;
} catch (URISyntaxException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

```

If your call to `browse` above raises an exception, you will never set the exit flag.

Why are you doing this in a loop? If your intent is to only do this step once, do it once as a statement rather than using a flow-control structure.