---
title: Hostname logic in Java
source: https://docs.newrelic.com/docs/apm/agents/java-agent/configuration/hostname-logic-java
---

The Java agent automatically assigns a `host:port` name to your JVMs. If the default name is not useful, you can [set a display name](#display-name) to distinguish your JVMs in the New Relic UI. For supported frameworks, the Java agent uses the [instance name](#instance-names) instead of the display name.

The Java agent uniquely identifies running agents [by their host, port, and dispatcher](#unique-identifier), regardless of the environment used.

## Display names [#display-name]

If the default `host:port` label in the APM UI is not useful, you can decorate that name in the New Relic UI with a [display name](https://docs.newrelic.com/docs/apm/new-relic-apm/maintenance/add-rename-remove-hosts#display_name). Set the display name via [configuration](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file), either in an environment variable or in your **newrelic.yml** config file. The environment variable takes precedence over the config file value. After the JVM is restarted and the Java agent is reporting again , the display name will show in the JVM list as seen in the example below in addition to `host:port`.

To set a display name:

-   Set the [`NEW_RELIC_PROCESS_HOST_DISPLAY_NAME`](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#NEW_RELIC_PROCESS_HOST_DISPLAY_NAME) environment variable.  
    OR
-   Set [`process_host.display_name`](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#display_name) in your **newrelic.yml**.

Restart your JVM to see your changes in the New Relic UI.

> #### 💡 TIP
>
> You can also set the display name with a [system property](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#System_Properties).

![upload.png](https://docs.newrelic.com/images/apm_screenshot-crop_java-edit-host-name.webp "display_name example")

## Instance names

For WebSphere and WebLogic users, the Java agent also reports the instance name for each active app server instance, which is visible in the APM **Settings > Environment** page. Generally, this name is provided by the app server. If an instance name is set, it will be used instead of the display name in the New Relic UI.

## Hostname logic precedence [#precedence]

If there are multiple hostname settings (for example, you use WebSphere and also set the `display_name` property), the agent uses this precedence:

-   `display_name` overrides the default name, and the WebSphere and WebLogic instance names.
-   WebSphere and WebLogic instance names override the default name.
-   The default (`host:port`) name has lowest precedence.

## Hosts and unique agent identifiers [#unique-identifier]

The Java agent uses hosts, ports, and dispatchers to uniquely identify multiple JVMs reporting to the same app name. Multiple agents running on the same server are therefore reported separately, as long as their ports or dispatcher names differ.

The unique identifier is based on the following values:

-   **Host**: An identifier for your app's parent server that is derived from the Operating System. This value is not configurable by the Java agent.
-   **Port**: The port associated with the app server. If the agent can't determine the port number, or your app is not running in an app server, defaults to **0**. This value is user-configurable.
-   **Dispatcher Name**: The name of the app server. For example, Apache Tomcat, Glassfish, or WebLogic. If there is no active app server, defaults to **Unknown**.
