Monday, 16 June 2014

Install Mozilla Firefox addon programmatically

This blog summarizes the procedure to install Mozilla Firefox addon programmatically.

We do have a command '-install-global-extension' to install addons for the firefox versions that are earlier than ver 3.6. (Refer:

For the latest firefox versions, Mozilla does not support the above mentioned command. Hence we need to install addons through some work arounds.

This blog details about how to install addons programmatically for latest versions of firefox, which do not support '-install-global-extension' command.

Usually, firefox addons are installed at the user level and not at the system level. In other words, if you install a firefox addon - it will be available only for the user who installed it. If another user logins to the same machine with his credentials, addon will not be available to him/her.

User can install the addon either by dragging and dropping the .xpi files into firefox browser or by placing the xpi file in the below location:


If user installs the addon by placing the .xpi file in the above location, firefox will prompt the user to install the addon at the next launch of firefox.

Some points to be noted here:

1. Usually 'AppData' folder will be a hidden folder. Hence we need to change the windows folder setting to display it.
2. '.default' folder will precede with some random text. For every user, this random text will change. Hence we need to handle this programmatically.
3. We need to ensure that .xpi file is named with the same value of '<em:id>' parameter as defined in the install.rtf file.

So, to install addon programmatically, we just need to copy and paste our .xpi file into the location mentioned above. Below code mentions how to find the .default file using regular expression. After finding the location, you are just required to copy and paste the xpi file into the identified location:



public class New {
                static String dataFolder = System.getProperty("user.home") + "\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles";
  public static void main(String[] args) {
                 File dir = new File(dataFolder);
                 FileFilter fileFilter = new RegexFileFilter(".*default");
                 File[] files = dir.listFiles(fileFilter);
                 File extDir = new File(files[i]+"\\extensions")

Please let me know if you have any queries with respect to above explanation.


  1. mozilla firefox has grown very rapidly and became one of the browser that has many users

  2. Firefox plugin development is gaining momentum in the global landscape of various browsing environments to improve browsing experience of the users and developers to create websites quickly and easily. In this piece of write up, some popular Firefox plugins have been discussed, which are widely used by users and web developers. firefox 57