# WinAssociations

Import: `import com.install4j.api.windows.WinAssociations;`

```java
public class WinAssociations
```

Collection of static methods to create and remove file associations
on Microsoft Windows.

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`create(String, String, File, File)`](#create-string-string-file-file) | `void` | Creates a file association. |
| [`exists(String)`](#exists-string) | `boolean` | Checks whether a file association already exists. |
| [`getExecutable(String)`](#getexecutable-string) | `String` | Retrieves the executable associated with an extension. |
| [`remove(String)`](#remove-string) | `void` | Removes a file association. |

### create(String, String, File, File)

```java
public static void create(String extension, String description, File iconFile, File executable)
```

Creates a file association.


**Parameters:**

- `extension` — the extension including the leading dot (e.g. ".doc").
- `description` — a description of the file type.
- `iconFile` — the icon file for the document. Can be null.
- `executable` — the executable that shall be called with the file
as a parameter.

### exists(String)

```java
public static boolean exists(String extension)
```

Checks whether a file association already exists.


**Parameters:**

- `extension` — the extension including the leading dot (e.g. ".doc").

**Returns:** true if an association exists

### getExecutable(String)

```java
public static String getExecutable(String extension)
```

Retrieves the executable associated with an extension.


**Parameters:**

- `extension` — the extension including the leading dot (e.g. ".doc").

**Returns:** the executable associated with the given extension. Null if there is no association.

### remove(String)

```java
public static void remove(String extension)
```

Removes a file association.


**Parameters:**

- `extension` — the extension including the leading dot (e.g. ".doc").

