Preparing a Java Development Environment
Configuring the Environment
The Image Recognition Java SDK uses JDK 8 or later. The following uses JDK 8 (Windows x64) running on Windows 7 as an example. If you have downloaded the JDK and configured the environment, skip this section.
- Download the JDK file.
- After the JDK file is downloaded, install the JDK as prompted. For example, install the JDK to the C:\Program Files\Java\jdk1.8.0_131 directory on the local PC.
- Right-click Computer, choose Properties > Advanced System Settings > Environment Variables, and perform the following operations to configure Java environment variables:
- Create system variable JAVA_HOME whose value is the JDK installation path.
- Add %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin to Path. Separate multiple values with semicolons (;).
- Create system variable CLASSPATH whose value is %JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar.
- Open the command line interface (CLI) and run java -version. If the information shown in Figure 1 is displayed, the configuration is successful.
Obtaining and Installing an SDK
You are advised to use the Java SDK for Image Recognition by installing dependencies through Apache Maven.
- Download and install Apache Maven on your operating system.
- After installing and configuring Maven, run the mvn -v command. Maven is installed successfully if the following information is displayed.
- Add dependencies to an existing Maven project or use an integrated development environment (IDE) to create a Maven project.
For example, to create a Maven project using IntelliJ IDEA, perform the following steps (skip them if you already have a Maven project):
- Start IntelliJ IDEA.
- Choose File > New > project...
- In the displayed New Project dialog box, click Maven and then Next.
- Specify GroupId and ArtifactId, and click Next.
- Specify Project name and Project location, and click Finish.
- Add dependency items to the pom.xml file of the Maven project.
For example, obtain the latest version of Image Recognition SDK from SDK Center and use it to replace the version in the code.
<dependency> <groupId>com.huaweicloud.sdk</groupId> <artifactId>huaweicloud-sdk-image</artifactId> <version>3.1.8</version> ///Enter the latest SDK version. </dependency>
The following sample code uses the fastjson dependency (ignore and delete it if it is not required):
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.70</version> </dependency>
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot