This topic describes how to build a Java development environment in a Windows operating system. In the following example, IntelliJ IDEA is used.
What is a Java development environment?
A Java development environment is a collection of configurations and tools that are used to develop Java projects. It includes the Java Development Kit (JDK), an integrated development environment (IDE), such as IntelliJ IDEA, Eclipse, and VSCode, and build tools, such as Maven.
Install the JDK
For more information, see Install the JDK on Windows.
Install an IDE
In this example, IntelliJ IDEA Community is installed. To download IntelliJ IDEA Community, visit IntelliJ IDEA Community download page, and click Download. After you download IntelliJ IDEA Community, install it as prompted.

Important When you install IntelliJ IDEA Community, select Add "bin" folder to the PATH in the Installation Options step. In other steps, click Next.
Create a Maven project
Open IntelliJ IDEA and click New Project.
IntelliJ IDEA is an JDE that provides a wide range of features to help you compile, test, build, run, and deploy projects. The IDE facilitates software application mamagement and maintainence for developers.

In the left-side navigation pane of the New Project window, click Java and configure the following parameters in the right-side section:
Name: The name of the project. In this example, helloaliyun is used.
Location: The path to the project file.
Build system: The type of the project. If you select Maven, a Maven project is created.
JDK: The JDK version. In this example, JDK 8 is selected.
Note To select a JDK, click Add JDK, select the JDK that is installed, and then select the directory in which the JDK is installed.
Add sample code: Specifies whether to add sample code. If you select the checkbox, a Main class is created.

Click Create.
Then, a project named helloaliyun is created. The project contains a pom.xml file, a src/main/java directory, and a Main class.

Check whether the Java development environment is built.
In the src/main/java directory of the project, find the Main class in the org.example package, double-click the class name to open the file, and then click the Run icon in the upper-right corner.

Check whether an output of Hello World! is displayed in the console. If the output is displayed, the Java development environment is built on Windows.

What to do next
After you build a Java development environment, you can use the Java development environment in actual development scenarios. Examples and user guides:
1. Use an SDK for Java to call Alibaba Cloud APIs
Before you make a call, you need to obtain an AccessKey pair as the access credential. We recommend that you use the AccessKey pair of a Resource Access Management (RAM) user. For more information, see Create an AccessKey pair.
Log on to the SDK Center, and select the service that you want to use, such as the DescribeInstanceTypeFamilies API operation of Elastic Compute Service (ECS).
On the Parameters tab in the middle of the page, configure the required parameters. You can refer to the Document tab on the right side to learn the descriptions and usagenotes of the operation, especially the billing rules, and the definitions and usage of each parameter. For example, the DescribeInstanceTypeFamilies operation supports two parameters, where the RegionId parameter is required and you can enter cn-qingdao, which indicates the China (Qingdao) region. The Generation parameter is optional and you can enter ecs-5, which indicates the series V instance family. You can view the detailed parameter values on the Document tab on the right side. Enter parameter values in the formats given in the examples.
On the SDK Sample Code tab on the right side of the page, select the Java language, click Download Project to download the complete SDK project to your local machine, and decompress the project.
Sample code:
import com.aliyun.ecs20140526.Client;
import com.aliyun.ecs20140526.models.DescribeInstanceTypeFamiliesRequest;
import com.aliyun.ecs20140526.models.DescribeInstanceTypeFamiliesResponse;
import com.aliyun.tea.TeaException;
import com.aliyun.teaopenapi.models.Config;
import com.google.gson.Gson;
public class Sample {
public static void main(String[] args) {
try {
Config config = new Config()
// System.getenv indicates that the key is obtained from environment variables.
.setAccessKeyId(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID"))
.setAccessKeySecret(System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET"));
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
Client client = new Client(config);
DescribeInstanceTypeFamiliesRequest describeInstanceTypeFamiliesRequest = new DescribeInstanceTypeFamiliesRequest();
describeInstanceTypeFamiliesRequest.setRegionId("cn-qingdao");
describeInstanceTypeFamiliesRequest.setGeneration("ecs-5");
DescribeInstanceTypeFamiliesResponse describeInstanceTypeFamiliesResponse = client.describeInstanceTypeFamilies(describeInstanceTypeFamiliesRequest);
System.out.println(new Gson().toJson(describeInstanceTypeFamiliesResponse));
} catch (TeaException teaException) {
// Display the error code.
System.out.println(teaException.getCode());
// Display the error message that contains the request ID.
System.out.println(teaException.getMessage());
// Display the detailed error information that is returned by the server.
System.out.println(teaException.getData());
} catch (Exception e) {
TeaException error = new TeaException(e.getMessage(), e);
// The error message.
System.out.println(error.getMessage());
// The URL for troubleshooting.
System.out.println(error.getData().get("Recommend"));
com.aliyun.teautil.Common.assertAsString(error.message);
}
}
}
Expected result:
For more information about how to use Alibaba Cloud SDK for Java to call Alibaba Cloud APIs, see Use Alibaba Cloud SDKs for Java in an IDE.
2. Call the Qwen API to start conversations
Alibaba Cloud Model Studio allow you to use large models by calling APIs, which can be called through API Explorer or DashScope SDKs. Before you call the service, you need to activate Alibaba Cloud Model Studio and obtain an API key. For more information, see the "Manage account" section in Make your first API call to Qwen.
Important After you obtain the API key, specify it in the environment variable to prevent API key leaks. Do not expose the API key in the code. For more information, see the "Set the API key in the environment variable" section in Make your first API call to Qwen.
Add the following dependency to the pom.xml file to install the the SDK for Java:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
<!-- Replace 'the-latest-version' with the latest version number obtained from https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java -->
<version>the-latest-version</version>
</dependency>
After you install Java and the SDK for Java, you can run the following sample code to call the Qwen API:
package org.example.nlp.ai;
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
public class Sample {
public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {
Generation gen = new Generation();
Message systemMsg = Message.builder()
.role(Role.SYSTEM.getValue())
.content("You are a helpful assistant.")
.build();
Message userMsg = Message.builder()
.role(Role.USER.getValue())
.content("Who are you?")
.build();
GenerationParam param = GenerationParam.builder()
// System.getenv indicates that the API key is obtained from the environment variable. If no environment variable is configured, replace the following line with: api_key="sk-xxx" by using your Alibaba Cloud Model Studio API Key.
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("qwen-plus")
.messages(Arrays.asList(systemMsg, userMsg))
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.build();
return gen.call(param);
}
public static void main(String[] args) {
try {
GenerationResult result = callWithMessage();
System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
System.err.println("Error message:"+e.getMessage());
}
System.exit(0);
}
}
Expected output:
For more information about how to call the Qwen API, see the Java tab in the "Select a development language" section in OpenAI JavMake your first API call to Qwena SDK.
3. Call the DeepSeek API
This section describes how to call DeepSeek models by using API operations on the Alibaba Cloud Model Studio platform. deepseek-r1 and deepseek-v3 provide one million free tokens. Some of the distillation models are free of charge for a limited period of time.
Before you call the service, you need to activate Alibaba Cloud Model Studio and obtain an API key. For more information, see the "Manage account" section in Make your first API call to Qwen.
Important After you obtain the API key, specify it in the environment variable to prevent API key leaks. Do not expose the API key in the code. For more information, see the "Set the API key in the environment variable" section in Make your first API call to Qwen.
Add the following dependency to the pom.xml file to install the SDK for Java:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dashscope-sdk-java</artifactId>
<!-- Replace 'the-latest-version' with the latest version number from https://mvnrepository.com/artifact/com.alibaba/dashscope-sdk-java -->
<version>the-latest-version</version>
</dependency>
Important The DashScope SDK version must be 2.18.2 or later.
After you install Java and the SDK for Java, you can run the following sample code to call the DeepSeek model service:
import java.util.Arrays;
import java.lang.System;
import com.alibaba.dashscope.aigc.generation.Generation;
import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.generation.GenerationResult;
import com.alibaba.dashscope.common.Message;
import com.alibaba.dashscope.common.Role;
import com.alibaba.dashscope.exception.ApiException;
import com.alibaba.dashscope.exception.InputRequiredException;
import com.alibaba.dashscope.exception.NoApiKeyException;
public class Sample {
public static GenerationResult callWithMessage() throws ApiException, NoApiKeyException, InputRequiredException {
Generation gen = new Generation();
Message userMsg = Message.builder()
.role(Role.USER.getValue())
.content("Which is larger, 9.9 or 9.11?")
.build();
GenerationParam param = GenerationParam.builder()
// If no environment variable is configured, replace the following line with: .apiKey("sk-xxx") by using your Alibaba Cloud Model Studio API Key.
.apiKey(System.getenv("DASHSCOPE_API_KEY"))
.model("deepseek-r1")
.messages(Arrays.asList(userMsg))
// Do not set the value to text.
.resultFormat(GenerationParam.ResultFormat.MESSAGE)
.build();
return gen.call(param);
}
public static void main(String[] args) {
try {
GenerationResult result = callWithMessage();
System.out.println("Thinking process:");
System.out.println(result.getOutput().getChoices().get(0).getMessage().getReasoningContent());
System.out.println("Final answer:");
System.out.println(result.getOutput().getChoices().get(0).getMessage().getContent());
} catch (ApiException | NoApiKeyException | InputRequiredException e) {
// Use a logging framework to record exception information.
System.err.println("An error occurred while calling the generation service: " + e.getMessage());
}
System.exit(0);
}
}
Expected output: