All Products
Search
Document Center

Simple Message Queue (formerly MNS):Install SDK for Java

Last Updated:Mar 26, 2025

If you want to use Simple Message Queue (formerly MNS) to send and receive messages, you can use SMQ SDK for Java. This topic describes how to install SMQ SDK for Java.

Environment requirements

  • Java Development Kit (JDK) 1.6.0 or later is installed. For more information, see Java Downloads.

    You can run the java -version command to check the Java version.

  • Maven 2.5 or later is installed. For more information, see Downloading Apache Maven 3.9.8.

Install the Java dependency

Note
  • Select a version of SMQ SDK for Java based on your business requirements. We recommend that you use the latest version of SMQ SDK for Java.

  • For more information about the versions of SMQ SDK for Java, see Versions.

<dependency>
    <groupId>com.aliyun.mns</groupId>
    <artifactId>aliyun-sdk-mns</artifactId>
    <version >${ Latest version of MNS SDK for Java}</version>
</dependency>

Add JAXB dependency

If you use Java 9 or later, you must add the following Java Architecture for XML Binding (JAXB) dependencies.

  • If you use the non-module system such as Classpath, you need to add the following dependencies.

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.9</version>
    </dependency>
  • If you use the module system, add the following requires declarations to your module-info.java file.

    module your.module.name {
        requires java.xml;  // Declare the dependency on the standard XML module. 
        requires aliyun.sdk.mns; // Declare the dependency on the SMQ SDK module. 
    
      
        // Declare the dependencies on other modules.
    }