Send an SMS Using Java

The TextMagic API Java wrapper can save you a lot of time, as it includes all the necessary API commands and tests. It only takes a few seconds to download it from GitHub and to install it into your own app or software. After installation, you'll then be able to send text messages.

Get it now on GitHub
Java logo

Installation Instructions

Quick Installation

The easiest way to install the TextMagic Java wrapper is from Maven. You can add the following dependency to your existing project, specifying the latest version in the version tag:


Manual Installation

You can also install the TextMagic Java wrapper from the GitHub repository using git. Run the following commands:

git clone git://
cd textmagic-rest-java
mvn install


The Java wrapper has the following requirements:

  • Java SE6 or higher
  • Apache Maven 2.0 or higher

Send an SMS using Java (an example)

Below is an example on how to send a text message using Java.

package com.textmagic.sdk;

import com.textmagic.sdk.RestClient;
import com.textmagic.sdk.RestException;
import com.textmagic.sdk.resource.instance.*;
import java.util.Arrays;

public class Example{
  public static void main(String[] args) throws RestException {
    RestClient client = new RestClient("<USERNAME>", "<APIV2_KEY>");

    TMNewMessage m = client.getResource(TMNewMessage.class);
    m.setText("Hello from TextMagic Java");
    m.setPhones(Arrays.asList(new String[] {"99900000"}));
    try {
    } catch (final RestException e) {
      throw new RuntimeException(e);


If you need help with the wrapper, or if you have any suggestions for improvements and/or if you have enquiries regarding the Java SMS gateway, please contact us by emailing .