# Generating a session ID

Before running the build scan and tests, you need to create a session ID. The session ID is provided for each step to link them together as one complete cycle.&#x20;

## Generating a session ID in Java <a href="#generating-a-session-id-in-java" id="generating-a-session-id-in-java"></a>

Generating a session ID in Java is done using the Java Build scanner with the `-config` flag and requires to specify a comma-separated list of packages composing the application.

{% code overflow="wrap" lineNumbers="true" %}

```java
java -jar sl-build-scanner.jar -config -tokenfile /path/to/sltoken.txt -appname "myApp" -branchname "master" -buildname "1" -pi "*com.company.*"
```

{% endcode %}

{% hint style="info" %}
See [#inlineextension-creating-a-session-id](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/command-reference#inlineextension-creating-a-session-id "mention") for full parameter details
{% endhint %}

{% hint style="warning" %}
If you don’t know the list of packages of the application, please refer to our dedicated command described in a detailed documentation page: [which-packages-to-configure](https://docs.sealights.io/knowledgebase/setup-and-configuration/troubleshooting-faq/java/which-packages-to-configure "mention").
{% endhint %}

{% hint style="info" %}
The `buildname` parameter above should reflect a meaningful versioning of your service or application.\
In some cases, you can use timestamps as well, via commands like `` `date +"%y%m%d_%H%M"` `` (Linux) or `$(Get-Date -Format "yyyyMMdd_HHmm")` (Powershell)
{% endhint %}

## Using the session ID <a href="#using-the-session-id" id="using-the-session-id"></a>

The session ID will be printed to the console output and a file called 'buildSessionId.txt' will be generated containing it.

The file can be used as is in the different agents parameters or can be used to fill in an environment parameter to be in a command line.

{% tabs %}
{% tab title="Unix" %}
{% code overflow="wrap" lineNumbers="true" %}

```
export SL_BUILD_SESSION_ID=`cat buildSessionId.txt`
```

{% endcode %}
{% endtab %}

{% tab title="Windows" %}
{% code overflow="wrap" lineNumbers="true" %}

```
set /p SL_BUILD_SESSION_ID=<buildSessionId.txt
```

{% endcode %}
{% endtab %}
{% endtabs %}
