> 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/cd-agent/java-agent-cd-only-mode.md).

# Java Agent - CD Only Mode

## Overview

The Java Agent runs directly alongside your Java application as a JVM `javaagent`.

Each deployed component should run its own SeaLights agent instance.

## Prerequisites

Before onboarding:

* Obtain a SeaLights Agent Token
* Ensure HTTPS access to SeaLights
* Have access to modify JVM startup parameters

## Downloading the Agent

Download and extract the latest Java Agent:

{% tabs %}
{% tab title="Bash" %}

```bash
wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip && \
unzip -oq sealights-java-latest.zip && \
cat version.txt
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
Invoke-WebRequest -Uri "https://agents.sealights.co/sealights-java/sealights-java-latest.zip" -OutFile "sealights-java-latest.zip"
Expand-Archive -Path "sealights-java-latest.zip" -DestinationPath "sealights-java" -Force
Get-Content .\sealights-java\version.txt
```

{% endtab %}
{% endtabs %}

The package contains:

* `sl-build-scanner.jar`
* `sl-test-listener.jar`
* `sealights-java-version.txt`

## CD Only Mode Configuration

CD Only mode is enabled using:

```bash
sl.mode=scanAndCoverage
```

This mode combines:

* Application code scan phase
* Coverage collection during test execution phase

## Required System Properties

<table><thead><tr><th width="290.53125">System Properties</th><th>Description</th></tr></thead><tbody><tr><td><code>-Dsl.mode=scanAndCoverage</code></td><td>(Mandatory for CD Only mode) Enables CD Only mode.</td></tr><tr><td><code>-Dsl.token</code> or <code>-Dsl.tokenFile</code></td><td>SeaLights agent token.</td></tr><tr><td><code>-Dsl.appName</code></td><td>Application/component name.</td></tr><tr><td><code>-Dsl.buildName</code></td><td>Version/build identifier.</td></tr><tr><td><code>-Dsl.labId</code></td><td>Unique lab identifier.</td></tr><tr><td><code>-Dsl.includePackages</code></td><td>Comma-separated list of packages to scan. Supports wildcards (<code>*</code> = any string, <code>?</code> = any character). Example, <code>com.mycompany.service.* ,com.acme,orders.*, io.company.*.api</code>.</td></tr></tbody></table>

## Optional System Properties

These System Properties may be required depending on your specific configuration or environment limitations (for example, proxy configuration).

<table><thead><tr><th width="221.10546875">System Properties</th><th>Description</th></tr></thead><tbody><tr><td><code>-Dsl.branchName</code></td><td>Component branch name. Defaults to <code>unspecified</code> if not provided.</td></tr><tr><td><code>-Dsl.scanDir</code></td><td>Folders to search for files to be scanned (Default: current working directory).</td></tr><tr><td><code>-Dsl.includeFiles</code></td><td>Comma-separated list of files to scan. Supports wildcards (<code>*</code> = any string, <code>?</code> = any character). <strong>Note:</strong> Each file is evaluated using its full path. Unless specifying the full path explicitly, the pattern should begin with <code>*</code>. Example, <code>*original-*.jar, *demo?.jar</code>.</td></tr><tr><td><code>-Dsl.excludeFiles</code></td><td>Comma-separated list of search patterns with wildcards for files to exclude from the scan.<br><strong>Note:</strong> Each file is evaluated using its full path. Unless specifying the full path explicitly, the pattern should begin with <code>*</code>. Example, <br><code>*-with-dependencies.jar , *bad-bad?.war, *-source.jar</code>.</td></tr><tr><td><code>-Dsl.excludePackages</code></td><td>Comma-separated list of packages to exclude from scan. Supports wildcards (<code>*</code> = any string, <code>?</code> = any character). Example, <code>com.mycompany.test.*, io.*.demo, com.acme.*mock*, com.company.internal.*</code>.</td></tr><tr><td><code>-Dsl.recursive</code></td><td>Enables recursive scanning of workspace paths. Default value is <code>true</code>.</td></tr><tr><td><code>-Dsl.proxy</code></td><td>Proxy configuration used by the agent when communicating with SeaLights.</td></tr><tr><td><code>-Dsl.tags</code></td><td>Free-text comma-separated tags used to help identify agents later in the Cockpit.</td></tr></tbody></table>

## Examples

{% tabs %}
{% tab title="Standalone JVM" %}

```bash
java \
-javaagent:/sealights/sl-test-listener.jar \
-Dsl.mode=scanAndCoverage \
-Dsl.token=${SL_TOKEN} \
-Dsl.appName=<component-name> \
-Dsl.buildName=<component-build-name> \
-Dsl.labId=<test-env-id> \
-Dsl.includeFiles=*original-*.jar \
-jar app.jar
```

{% endtab %}

{% tab title="JAVA\_TOOL\_OPTIONS (Bash)" %}

```bash
export JAVA_TOOL_OPTIONS="\
-javaagent:/sealights/sl-test-listener.jar \
-Dsl.mode=scanAndCoverage \
-Dsl.tokenFile=/sealights/sltoken.txt \
-Dsl.appName=<component-name> \
-Dsl.buildName=<component-build-name> \
-Dsl.labId=<test-env-id> \
-Dsl.includeFiles=*original-*.jar"

##Run the application
##java -jar app.jar
```

{% endtab %}

{% tab title="JAVA\_TOOL\_OPTIONS (PowerShell)" %}

```powershell
$env:JAVA_TOOL_OPTIONS = @"
-javaagent:C:\sealights\sl-test-listener.jar
-Dsl.mode=scanAndCoverage
-Dsl.tokenFile=C:\sealights\sltoken.txt
-Dsl.appName=<component-name>
-Dsl.buildName=<component-build-name>
-Dsl.labId=<test-env-id>
-Dsl.includeFiles=*original-*.jar
"@

##Run the application
##java -jar app.jar
```

{% endtab %}
{% endtabs %}

## Logging

Enable console logging:

```bash
-Dsl.log.enabled=true \
-Dsl.log.level=info \
-Dsl.log.toConsole=true
```

Enable file logging:

```bash
-Dsl.log.level=info \
-Dsl.log.toFile=true \
-Dsl.log.folder=/tmp/sealights-logs
```

## Validation

Once the application starts:

* Navigate to: `Cockpit → Live Agents Monitor`
* Verify the agent appears online

You can also validate JVM arguments locally:

{% tabs %}
{% tab title="Bash" %}

```bash
ps -ef | grep java
```

{% endtab %}

{% tab title="PowerShell" %}

```powershell
Get-CimInstance Win32_Process | `
Where-Object { $_.Name -like '*java*' } | `
Select-Object CommandLine, ProcessId
```

{% 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sealights.io/knowledgebase/setup-and-configuration/sealights-agents-and-plugins/cd-agent/java-agent-cd-only-mode.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
