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
2010-06-16 13:55:30
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
2010-06-16 13:57:40
@Richard, I was just editing while you posted that comment. I agree: there's no "fool proof" solution.
Bart Kiers
2010-06-16 13:58:45
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
2010-06-16 14:02:11
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
2010-06-16 13:58:10
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
2010-06-16 13:59:21
Java and registry? What about *nix systems or MacOS, these don't have a registry.
Bart Kiers
2010-06-16 14:00:03