karthick
karthick

Reputation: 12176

How to Detect browsers installed in a system

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

Upvotes: 4

Views: 2887

Answers (3)

manjeet lama
manjeet lama

Reputation: 305

For windows you can get this in formation from registry:

To get this information from java.

1) create batch file browsers.bat with following script.

echo Browsers> browsers.txt for /f "skip=4 delims=" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet" 2^>nul') do ( echo %%~nA 1>>browsers.txt ) exit

2) Invoke the batch file from java using following command. Process p = Runtime.getRuntime().exec("cmd /c start browsers.bat", null, new File("C:\Users\batch-file-path"));

This will store all the available browsers in browsers.txt file.

Upvotes: 1

yurib
yurib

Reputation: 8147

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

Upvotes: 0

Bart Kiers
Bart Kiers

Reputation: 170298

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.

Upvotes: 5

Related Questions