tags:

views:

73

answers:

2

Using Java, how can I detect all of the browsers that are installed on a system?

+3  A: 

You can't.

You can open a page using the default browser on a system with Java 6 *, but you can't list all browsers installed on a system.

Sure, you can iterate over Windows' C:\Program Files\ folder or *nix's /usr/local (or other dirs) to check for browser names, but you might run into user-privilege issues and you're never guaranteed to get all browsers, nor is this OS independent.

Bart Kiers
If you knew the OS I guess you could check for existence of the various browser exe's in all the usual places? Not bullet proof by any means, but might suffice.
Richard
@Richard, I was just editing while you posted that comment. I agree: there's no "fool proof" solution.
Bart Kiers
What is "usual places"? In Linux/Unix world, there is no such thing as "usual place". Some may install it in /bin, /usr/bin/, /opt/, /usr/local/bin/, /home/username/browser/, etc... and many distro mixes them up. Even in Windows, it's possible to install a program not in Program Files.
Lie Ryan
A: 

Don't think you can detect ALL browsers installed on a system but you could check whether a specific one is installed by looking in the registry

yurib
This will only work for windows, and at that you may run into permissions issues or be redirected to the virtual store in which case you will get nothing.
Corazu
Java and registry? What about *nix systems or MacOS, these don't have a registry.
Bart Kiers
you're right, i guess i didn't think this through
yurib