> 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/troubleshooting-faq/java/keeping-your-agent-updated.md).

# Keeping Your Agent Updated

How to ensure I am running the latest/recommended agent version

### Problem <a href="#problem" id="problem"></a>

When configuring the SeaLights agent for Java, it is difficult to manage the .jar files are in the correct version - especially in standalone environments (containers, backend servers etc)

### Solution <a href="#solution" id="solution"></a>

The following shell script checks for the recommended agent and latest version, and in case it does not exist locally - downloads & unzips it in the given directory.

#### Downloading the Recommended Agent set in settings <a href="#downloading-the-recommended-agent-set-in-settings" id="downloading-the-recommended-agent-set-in-settings"></a>

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

```sh
#!/bin/bash

export DOMAIN=<CustomerDomain>.sealights.co
export SEALIGHTS_AGENT_TOKEN=`cat sltoken.txt`

if [ -f "sealights-java-agent.zip" ]; then
    export SL_LOCAL_VERSION=`cat sealights-java-version.txt`
    export SL_SETTINGS_VERSION=`curl -sX GET "https://$DOMAIN/sl-api/v1/agent-apis/agents/types/sealights-java/default-version" -H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" -H "accept: application/json" | jq  -r .version`
    
    if [ "${SL_LOCAL_VERSION}" == "${SL_SETTINGS_VERSION}" ]; then
        echo "Skipping Download - Local agent matches the current latest version:" $SL_SETTINGS_VERSION
    else
        echo "Local agent is not using the latest version. Deleting local agent."
        rm -fr sealights-java-*  sl-*.jar     
    fi
fi

if [ ! -f "sealights-java-agent.zip" ]; then
    echo "Downloading Java Agent version set in Settings..."
    wget -nv -O sealights-java-agents.zip --header "accept: application/json" --header "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
        https://$DOMAIN/api/v2/agents/sealights-java/recommended/download

    unzip -oq sealights-java-agents.zip
    echo "Local agent version is now:" `cat sealights-java-version.txt`
fi
```

{% endcode %}

#### Downloading the latest agent <a href="#downloading-the-latest-agent" id="downloading-the-latest-agent"></a>

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

```sh
#!/bin/bash

if [ -f "sealights-java-latest.zip" ]; then
    export LOCL_SL_VERSION=`cat sealights-java-version.txt`
    export CURR_SL_VERSION=`curl -s https://agents.sealights.co/sealights-java/sealights-java-version.txt`
    
    if [ "${LOCL_SL_VERSION}" == "${CURR_SL_VERSION}" ]; then
        echo "Skipping Download - Local agent matches the current latest version:" $CURR_SL_VERSION
    else
        echo "Local agent is not using the latest version. Deleting local agent."
        rm -fr sealights-java-*  sl-*.jar     
    fi
fi

if [ ! -f "sealights-java-latest.zip" ]; then
    echo "Downloading Sealights Latest Agent..."
    wget -nv https://agents.sealights.co/sealights-java/sealights-java-latest.zip
    unzip -o sealights-java-latest.zip
    echo "Local agent version is now:" `cat sealights-java-version.txt`
fi

```

{% endcode %}


---

# 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/troubleshooting-faq/java/keeping-your-agent-updated.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.
