| title | Azure Relay Hybrid Connections - HTTP requests in Java |
|---|---|
| description | Write a Java console application for Azure Relay Hybrid Connections HTTP requests. |
| ms.topic | tutorial |
| ms.date | 01/24/2026 |
| ms.custom | devx-track-java, mode-ui, mode-api, devx-track-extended-java |
[!INCLUDE relay-selector-hybrid-connections]
In this quickstart, you create Java sender and receiver applications that send and receive messages by using the HTTP protocol. The applications use Hybrid Connections feature of Azure Relay. To learn about Azure Relay in general, see Azure Relay.
In this quickstart, you take the following steps:
- Create a Relay namespace by using the Azure portal.
- Create a hybrid connection in that namespace by using the Azure portal.
- Write a server (listener) console application to receive messages.
- Write a client (sender) console application to send messages.
- Run applications.
- Java. Ensure that you're running JDK 1.8+
- Maven. Ensure that you have Maven installed
- Azure Relay SDK. Review Java SDK
- An Azure subscription. If you don't have one, create a free account before you begin.
[!INCLUDE relay-create-namespace-portal]
[!INCLUDE relay-create-hybrid-connection-portal]
To listen and receive messages from the Relay, write a Java console application.
[!INCLUDE relay-hybrid-connections-java-get-started-server]
To send messages to the Relay, you can use any HTTP client, or write a Java console application.
[!INCLUDE relay-hybrid-connections-java-get-started-client]
- Run the server application: from a Java command prompt or application type
java -cp <jar_dependency_path> com.example.listener.Listener.java. - Run the client application: from a Java command prompt or application type
java -cp <jar_dependency_path> com.example.sender.Sender.java, and enter some text. - Ensure that the server application console outputs the text that was entered in the client application.
Congratulations, you have created an end-to-end Hybrid Connections application using Java!
In this quickstart, you created Java client and server applications that used HTTP to send and receive messages. The Hybrid Connections feature of Azure Relay also supports using WebSockets to send and receive messages. To learn how to use WebSockets with Azure Relay Hybrid Connections, see the WebSockets quickstart.
In this quickstart, you used Java to create client and server applications. To learn how to write client and server applications using .NET Framework, see the .NET WebSockets quickstart or the .NET HTTP quickstart.