All Products
Document Center

Development environment on Windows

Last Updated: Jan 17, 2019

This article describes how to build a development environment quickly and start a simple Demo project in the Windows environment.

Install and configure Java

You can refer to Oracle official documents to learn how to install JDK. Download the img installation package for Mac OS and install it.

Note: Java 8 environment is recommended by default. You can also use Java 7 or later with the same configuration as Java 8.

To install Apache Maven, you need to download Apache Maven 3.2.5 or later and then install it locally. Refer to Apache Maven official documents to learn how to install Maven.

After installing Maven, configure environment variables under Windows, configure the M2_HOME environment variable, point to Maven installation directory, and append the bin directory to the PATH path.

Install IDEA

Download IDEA on the official website . After you have downloaded IDEA, follow the prompts to install IDEA.

Generate a certificate request and private key

Install OpenSSL

Skip this step if OpenSSL is already installed on your computer.

The steps for installing OpenSSL on the Windows operating system are as follows:

  1. Click hereto open the download page, locate version 1.0.20 (recommended), and download the installation package.

    Or click the link below to download directly:

  2. Open the command line tool and change to the bin directory of the OpenSSL installation path.

  3. Prepare the environment variable and enter set OPENSSL_CONF=openssl.cfg on the command line.

Create a certificate request and private key

Tollowing items are required:

  • A certificate request file (CSR. pem)
  • A private key file in pkcs8 format (key_pkcs8.pem)
  • A private key password (ssl_key_password)
  • A certificate file (cert .pem)
  • A certificate TrustStore file (trust.keystore)

The following explains in detail how to generate these files and content.

  1. Execute the openssl req -newkey rsa:2048 -keyout key_pkcs10.pem -out csr.pem command.

    While your command is being executed, you are required to enter the following information:

    • PEM pass phrase: The password, which is used as the value of the -passin parameter when the private key format is converted to the Private Key Information Standard Format (PKCS#8) in the next step.
    • Country name (2 letter code): Use the International Standards Organization (ISO) format here and enter the two-letter country code. For example, enter CN for China.
    • State or province name (full name): The province. For example, Zhejiang.
    • Locality name (for example, city): The city. For example, Hangzhou.
    • Organization name (for example, company): The organizational unit. For example, a company name.
    • Organizational unit name (for example, section): For example, IT Dept
    • Common name (for example, domain name of your website): The domain name of the website encrypted with SSL.Notes:

    This is not just your domain name, but a website name that uses SSL directly, such as

    Different URLs are defined here as different website domain names. For example:,, and are identified as three different website domain names.

    The website domain name here must be the same as the SMTP/POP3 server name set by the mail client software.

    • Email address: email address (optional)
    • Challenge password: (optional)
    • Optional company name: (optional)
  2. Convert the private key file in the preceding step from the certificate request format (PKCS#10) to the Private Key Information Standard Format (PKCS#8).

    1. # For the -passin parameter, enter the password when you create the certificate application in the preceding step. For the -passout parameter, set a new SSL private key password, which you will use when configuring the client
    2. openssl pkcs8 -topk8 -in key_pkcs10.pem -passin pass:****** -out key_pkcs8.pem -passout pass:******

    Note: Be sure to save your private key file key_pkcs8.pem, as you need it to initialize the client when you start a Demo.

  3. Upload the certificate application csr.pem.


  4. After the certificate application has been uploaded and submitted, it is reviewed in the background. Typically, the following two statuses are displayed:

    • Not Applied: The consortium chain has not yet been applied for.
    • Approved: Congratulations, you have successfully joined the consortium chain. You can download the signed user certificate and develop the SDK.


Start a demo

This section explains how to configure the project quickly to develop the first Demo.

  1. Log on to the BaaS platform, select Blockchain List in the left-side navigation pane, find the blockchain you want to access in the list, then select More on the right side, and click Download Signed Certificate and Download SDK respectively.apply_succeed

  2. Unzip the package obtained.

  3. Configure the file. The default configuration method is shown here. For more configuration methods, see Initialize the Client.

    1. # The address of the primary node to which the client is connected. One and only one primary node can be configured.
    2. biz.sdk.primary=### The IP configuration does not need to be modified ###
    3. # The API address of the backup node. You can configure n backup nodes, where n=3f : f=1,2...
    4. # When the primary node cannot be connected, the system switches to connect to the backup node. When the primary node recovers, it automatically switches back to connect to the primary node.
    5. biz.sdk.backups =### The IP configuration does not need to be modified ###
    6. # The client connects to the node using TLS mutual authentication, which requires the x509 certificate to be configured.
    7. # The absolute path of the SSL private key files in the pkcs8 format.
    8. biz.sdk.ssl_key=D:/path/key_pkcs8.pem
    9. # The absolute path of the SSL certificate files in the x509 format.
    10. biz.sdk.ssl_cert=D:/path/cert.pem
    11. # The SSL private key password set when the private key is created.
    12. biz.sdk.ssl_key_password=******
    13. # The absolute path of the TrustStore file
    14. biz.sdk.trust_store=D:/path/trust.keystore
    15. # The trust store password, which defaults to mychain and does not need to be modified.
    16. biz.sdk.trust_store_password=mychain

    Note: Replace D:/path/ with your actual absolute path.

  4. Create a new Maven project in IDEA and add the corresponding dependency package to the pom.xml file.

    1. <dependencies>
    2. <dependency>
    3. <groupId></groupId>
    4. <artifactId>antblockchain-gl-biz-sdk</artifactId>
    5. <version></version>
    6. <scope>system</scope>
    7. <systemPath>{libdir}/client-sdk.jar</systemPath>
    8. </dependency>
    9. <dependency>
    10. <groupId></groupId>
    11. <artifactId>antblockchain-sdk-plus</artifactId>
    12. <classifier>jar-with-dependencies</classifier>
    13. <version></version>
    14. <scope>system</scope>
    15. <systemPath>{libdir}/sdk-plus.jar</systemPath>
    16. </dependency>
    17. <dependency>
    18. <groupId>javax.validation</groupId>
    19. <artifactId>validation-api</artifactId>
    20. <version>1.1.0. Final</version>
    21. </dependency>
    22. <dependency>
    23. <groupId>org.hibernate</groupId>
    24. <artifactId>hibernate-validator</artifactId>
    25. <version>5.3.5. Final</version>
    26. </dependency>
    27. <dependency>
    28. <groupId>javax.el</groupId>
    29. <artifactId>javax.el-api</artifactId>
    30. <version>2.2.4</version>
    31. </dependency>
    32. <dependency>
    33. <groupId>org.glassfish.web</groupId>
    34. <artifactId>javax.el</artifactId>
    35. <version>2.2.4</version>
    36. </dependency>
    37. <dependency>
    38. <groupId></groupId>
    39. <artifactId>gson</artifactId>
    40. <version>2.8.5</version>
    41. </dependency>
    42. </dependencies>

    Note: Unzip the file downloaded from the BaaS platform, and add the client-sdk.jar and sdk-plus.jar dependencies included to the dependency directory. Note that libdir needs to be modified to the real path.

  5. After the configuration has been completed, you can create an SDK Client instance in the Main function of the project to obtain the transaction information of the latest block on the chain.

    1. import;
    2. import java.util.List;
    3. import java.util.Properties;
    4. import;
    5. import;
    6. import;
    7. import;
    8. import;
    9. import;
    10. public class App {
    11. public static void main(String[] args ) throws Exception{
    12. Properties p = new Properties();
    13. // Replace "D:/path/" with the real absolute path where the is stored
    14. p.load(new FileInputStream("D:/path/"));
    15. // Construct the client
    16. ClientConfig config = new ClientPropertyConfig(p);
    17. Client client = new Client(config);
    18. // Obtain the current block height
    19. int height = client.getLatestBlockHeader().getData().getHeight();
    20. // Obtain a block
    21. Response<Block> blockResponse = client.getBlock(height);
    22. // Obtain the transaction information on the block
    23. List<TransactionDO> trans = blockResponse.getData().getTransactions();
    24. // Shut down the client
    25. client.shutdown();
    26. }
    27. }

For more methods of using the SDK, see SDK Development Guide.