Use the System property:
String s = System.getProperty("java.version")
This will return a string like "1.3.1"; this is the version of the JRE that you are running under. As far as I can tell, it works whether you are running from the command line, appletviewer, an IDE, or a browser (with or without the plug-in).
HTH,
Carl Rapson