Question: I am trying to get a java gui to open a web page. So the gui runs some code that does things and then produces a html file.
I then want this file to open in a web browser (preferrably Firefox) as soon as it is created. 
How would I go about doing that?

Answer: 
If you're using Java 6 or above, see the [Desktop](http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html) API, in particular [browse](http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#browse(java.net.URI)). Use it like this (not tested):

```
// using this in real life, you'd probably want to check that the desktop
// methods are supported using isDesktopSupported()...

String htmlFilePath = "path/to/html/file.html"; // path to your new file
File htmlFile = new File(htmlFilePath);

// open the default web browser for the HTML page
Desktop.getDesktop().browse(htmlFile.toURI());

// if a web browser is the default HTML handler, this might work too
Desktop.getDesktop().open(htmlFile);

```
I've used [BrowserLauncher2](http://browserlaunch2.sourceforge.net/) with success. It'll invoke the default browser on all platforms tested. I use this for demoing software via JNLP. The software downloads, runs and drives the user's browser to information pages/feedback etc.

JDK 1.4 and above, I believe.