---
schema_version: "1"
id: b52bc219ea6fc88b06907ad9909a29aa7a52394588473fece3b0d2202dfca64d
title: Configuring the Java Version of a Custom Policy
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-gateway/policies-custom-java-version.md
canonical_url: https://docs.mulesoft.com/mule-gateway/policies-custom-java-version
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 7a44d0744437d9951f5d5bd61dda45990d797f8c367221b8e3e2b22f5fec3275
description: MuleSoft Documentation Site
latest: true
---
---
product: Mule Gateway
keywords: policy, endpoint
---

# Configuring the Java Version of a Custom Policy

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Mule Gateway custom policies can support different Java versions. To upgrade your custom policy to a
newer version of Java, ensure that all policy dependencies support the new Java version and add the
new Java version to your policy’s implementation metadata YAML file.

After you upgrade the policy:

1.  [Package the custom policy](https://docs.mulesoft.com/mule-gateway/policies-custom-package).

2.  [Republish the custom policy to Exchange](https://docs.mulesoft.com/mule-gateway/policies-custom-upload-to-exchange).

3.  [Upgrade your applied policies to the new policy version](https://docs.mulesoft.com/general/upgrade-policies-proxies).

## Before You Begin

Before upgrading the Java version of your policy, ensure all dependencies are compatible with that
Java version:

- If your policy is using custom connectors, see
  [Custom Connectors Java Support](https://docs.mulesoft.com/general/java-support#custom-connectors) to upgrade them.

- If your policy uses extensions provided by Mule API Gateway, update the version of the dependency
  in your `pom.xml` file to a version that supports your new Java version.

  For an example of how to use extensions in your custom policy, see
  [HTTP Policy Transform Extension](https://docs.mulesoft.com/mule-gateway/policies-custom-http-transform).

  To find the first Java 17-compatible version of the extension, see the following table. All
  versions support Java 8:

  <table><colgroup><col> <col></colgroup><tbody><tr><td><div><div><p>Extension artifact ID</p></div></div></td><td><div><div><p>First Java 17-compatible version</p></div></div></td></tr><tr><td><div><div><p>mule-client-id-enforcement-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-cors-extension</p></div></div></td><td><div><div><p>1.3.0</p></div></div></td></tr><tr><td><div><div><p>mule-event-authentication-extension</p></div></div></td><td><div><div><p>1.1.0</p></div></div></td></tr><tr><td><div><div><p>mule-federation-extension</p></div></div></td><td><div><div><p>1.4.0</p></div></div></td></tr><tr><td><div><div><p>mule-http-policy-transform-extension</p></div></div></td><td><div><div><p>3.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-http-proxy-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-ip-filter-extension</p></div></div></td><td><div><div><p>2.1.0</p></div></div></td></tr><tr><td><div><div><p>mule-json-threat-protection-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-jwt-extension</p></div></div></td><td><div><div><p>1.3.0</p></div></div></td></tr><tr><td><div><div><p>mule-rest-validator-extension</p></div></div></td><td><div><div><p>2.3.0</p></div></div></td></tr><tr><td><div><div><p>mule-soap-fault</p></div></div></td><td><div><div><p>2.1.0</p></div></div></td></tr><tr><td><div><div><p>mule-throttling-extension</p></div></div></td><td><div><div><p>3.1.0</p></div></div></td></tr><tr><td><div><div><p>mule-tokenization-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-wsdl-functions-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr><tr><td><div><div><p>mule-xml-threat-protection-extension</p></div></div></td><td><div><div><p>1.2.0</p></div></div></td></tr></tbody></table>

## Configure the Java Version of Your Policy

For your policy to support different Java versions, you must modify the implementation metadata file
to include the `supportedJavaVersions` field. The `supportedJavaVersions` supports the Java versions
`8`, `11`, and `17`. If you do not include the `supportedJavaVersions` field, your policy supports
only Java 8. As specified in [Before You Begin](#before-you-begin), all policy dependencies must
also support the listed Java versions.

For newer custom policies, your implementation metadata file and definition metadata file are split
into two separate `YAML` files. However, for older policies, your implementation metadata file and
definition metadata file might be included in the same `YAML` file. See the following sections the
add the `supportedJavaVersions` to your relevant file structure:

- [Split Model Policies](#split-model-policies)

- [Non-Split Model Policies](#non-split-model-policies)

### Split Model Policies

For split model policies, add the `supportedJavaVersions` field to the implementation metadata
`YAML`, for example:

```yaml
#%Policy Implementation 1.0
name: Basic Authentication - Simple - Mule4
technology: mule4
supportedJavaVersions: ["8", "11", "17"]
minRuntimeVersion: 4.1.0
releaseNotes: |
  * Java 17 compatibility.
```

### Non-Split Model Policies

For older policies where implementation and definition metadata are found in the same `YAML` file,
add the `supportedJavaVersions` field as follows:

```yaml
id: basic-authentication-simple
name: Basic authentication - Simple
supportedPoliciesVersions: ">=v1"
description: Enforces HTTP Basic authentication according to the details configured in the policy.
category: Security
violationCategory: authentication
type: system
resourceLevelSupported: true
encryptionSupported: true
standalone: true
supportedJavaVersions: ["8", "11", "17"]
requiredCharacteristics: []
providedCharacteristics:
  - Requires authentication
configuration:
  - propertyName: username
    name: User Name
    type: string
    optional: false
    sensitive: false
    allowMultiple: false
  - propertyName: password
    name: User Password
    type: string
    optional: false
    sensitive: true
    allowMultiple: false
```

## See Also

- [Java Support](https://docs.mulesoft.com/general/java-support)

- [Upgrading Java for Policies and API Proxies](https://docs.mulesoft.com/general/upgrade-policies-proxies)
