# Running as a Windows Service

## Prerequisites

**Note**  
The instructions on this page **do not apply** to _Sonatype IQ Server with bundled JDK_. For Windows service upgrades that use the bundled JDK, see [Upgrading IQ Server Installed as a Windows Service](https://help.sonatype.com/en/upgrading-the-iq-server.html#upgrading-iq-server-installed-as-a-windows-service).

1. Ensure you have already installed a supported JDK on the target system and the system meets our other [system requirements](https://help.sonatype.com/en/system-requirements.html?_ga=2.23364090.1364613275.1724085584-490197147.1715890912).

2. Download and extract the clm-jsw.zip file into a directory path that does not contain spaces.

clm-jsw.zip is available for download at [our support site](https://support.sonatype.com/hc/en-us/articles/213463798-Running-the-Sonatype-IQ-Server-as-a-Service-on-Windows).

3. Replace the extracted `./conf/config.yml` with the config.yml file from the current server installation.

Check the "sonatypeWork" property in the copied version to make sure it is correct.

4. Copy the nexus-iq-server-<version>.jar file from your installation into the `./lib/` directory.

This should be the only .jar file in the directory. Remove all older server .jar files from this folder.

## Start the Service

The service will run as the SYSTEM user. The server requires the use of a temporary directory.

The SYSTEM user will use `%systemroot%\System32\config\systemprofile\Temp` as the temporary directory.

On some versions of Windows, this directory does not exist by default. Create it manually if it does not.

1. Login as an administrator and run `.in\clm install`

2. Run `.in\clm start` to start the service. You can also start the service from the Windows Service Manager.

3. Verify that on restarting the host, the application will successfully restart itself.

## Optional Settings

### Change the Java executable to launch the server

You can explicitly specify the path to the java.exe file to launch the server using the following steps:

1. Edit `./bin/jsw/conf/wrapper.conf`

2. Find the un-commented line containing `wrapper.java.command=java` and change its value to include the include the **absolute path of the Java executable**, using forward slashes as path separators even on Windows.

**Example**  
```  
wrapper.java.command=F:/Software/Java/jdk-11.0.15/bin/java.exe
```

See [Java Service Wrapper documentation](https://wrapper.tanukisoftware.com/doc/english/prop-java-command.html).

### Edit the Java program arguments used to launch the server

You can edit the arguments of the java.exe file when the server is launched. These are parameter for the Java virtual Machine (JVM).

To change arguments passed to the java.exe program:

1. Edit `./bin/jsw/conf/wrapper.conf`

2. Find references to `wrapper.java.additional.<n>` properties.

Add or remove lines with new properties as specified in the [Java service wrapper documentation](https://wrapper.tanukisoftware.com/doc/english/prop-java-additional-n.html#additional).

**Example**: Configure a custom outbound truststore

To override the default Java truststore:

1. Edit `./bin/jsw/conf/wrapper.conf`

2. Specify `wrapper.java.additional.<n>` properties defining the trustStore and its password.

**Note**  
Make sure all paths specified use forward slashes. If the value requires a space, then the entire value must be in quotes.

```
wrapper.java.additional.4=-Djavax.net.ssl.trustStore=/<replace_with_absolute_full_path>/nexus-iq-server-outbound.jks
wrapper.java.additional.5=-Djavax.net.ssl.trustStorePassword=changeit
```
