This example introduces how to use Alibaba Cloud Java SDK to call the DescribeInstanceStatus API to obtain the instance status.

Code example

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.ecs.model.v20140526. DescribeInstanceStatusRequest;
import com.aliyuncs.ecs.model.v20140526. DescribeInstanceStatusResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;

public class ECSOperate {

	private static final String ACCESS_KEY = "";
	private static final String ACCESS_SECRET = "";
	private static IAcsClient client = null;

	static {
		// Create a profile
		IClientProfile profile = DefaultProfile.getProfile("cn-shenzhen", ACCESS_KEY, ACCESS_SECRET);
		// Create a client instance
		client = new DefaultAcsClient(profile);
	public static String describeInstanceStatus(FormatType formatType) {
		// Construct a request
		DescribeInstanceStatusRequest request = new DescribeInstanceStatusRequest();
		try {
			//Obtain the returned content
			return client.doAction(request).getHttpContentString();
			//Obtain the returned object
			//return client.getAcsResponse(request);
		} catch (ServerException e) {
			System.out.println("Server exception: " + e);
			return null;
		} catch (ClientException e) {
			System.out.println("Parameter configuration error: " + e);
			return null;
	public static void main(String[] args) {