> For the complete documentation index, see [llms.txt](https://docs.sealights.io/knowledgebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/generating-a-session-id.md).

# 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.

## 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" --includePackages "*com.company.*"
```

{% endcode %}

{% hint style="info" %}
See [Command Reference](/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/command-reference.md#inlineextension-creating-a-session-id) 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?](/knowledgebase/setup-and-configuration/troubleshooting-faq/java/which-packages-to-configure.md).
{% 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="Bash" %}
{% code overflow="wrap" lineNumbers="true" %}

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

{% endcode %}
{% endtab %}

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

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

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/java-agent/default-usage-cli/generating-a-session-id.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
