Skip to content

Commit d9c8cd5

Browse files
committed
Java Setup
1 parent 5335c4d commit d9c8cd5

File tree

4 files changed

+94
-33
lines changed

4 files changed

+94
-33
lines changed

articles/ai-services/computer-vision/how-to/background-removal.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Create a new **VisionSource** object from the URL of the image you want to analy
8686
**VisionSource** implements **IDisposable**, therefore create the object with a **using** statement or explicitly call **Dispose** method after analysis completes.
8787

8888
> [!TIP]
89-
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource.FromFile](/dotnet/api/azure.ai.vision.common.visionsource.fromfile)), or by copying the image into the SDK's input buffer (see [VisionSource.FromImageSourceBuffer](/dotnet/api/azure.ai.vision.common.visionsource.fromimagesourcebuffer)). For more details, see [Call the Analyze API](./call-analyze-image-40?pivots=programming-language-csharp#select-the-image-to-analyze).
89+
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource.FromFile](/dotnet/api/azure.ai.vision.common.visionsource.fromfile)), or by copying the image into the SDK's input buffer (see [VisionSource.FromImageSourceBuffer](/dotnet/api/azure.ai.vision.common.visionsource.fromimagesourcebuffer)). For more details, see [Call the Analyze API](./call-analyze-image-40.md?pivots=programming-language-csharp#select-the-image-to-analyze).
9090
9191
#### [Python](#tab/python)
9292

@@ -95,7 +95,7 @@ In your script, create a new [VisionSource](/python/api/azure-ai-vision/azure.ai
9595
[!code-python[](~/azure-ai-vision-sdk/docs/learn.microsoft.com/python/image-analysis/how-to/main.py?name=vision_source)]
9696

9797
> [!TIP]
98-
> You can also analyze a local image by passing in the full-path image file name to the **VisionSource** constructor instead of the image URL (see argument name **filename**). Alternatively, you can analyze an image in a memory buffer by constructing **VisionSource** using the argument **image_source_buffer**. For more details, see [Call the Analyze API](./call-analyze-image-40?pivots=programming-language-python#select-the-image-to-analyze).
98+
> You can also analyze a local image by passing in the full-path image file name to the **VisionSource** constructor instead of the image URL (see argument name **filename**). Alternatively, you can analyze an image in a memory buffer by constructing **VisionSource** using the argument **image_source_buffer**. For more details, see [Call the Analyze API](./call-analyze-image-40.md?pivots=programming-language-python#select-the-image-to-analyze).
9999
100100
#### [Java](#tab/java)
101101

@@ -106,7 +106,7 @@ Create a new **VisionSource** object from the URL of the image you want to analy
106106
**VisionSource** implements **AutoCloseable**, therefore create the object in a try-with-resources block, or explicitly call the **close** method on this object when you're done analyzing the image.
107107

108108
> [!TIP]
109-
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource.fromFile](/java/api/com.azure.ai.vision.common.visionsource#com-azure-ai-vision-common-visionsource-fromfile(java-lang-string)), or by copying the image into the SDK's input buffer (see [VisionSource.fromImageSourceBuffer](/java/api/com.azure.ai.vision.common.visionsource#com-azure-ai-vision-common-visionsource-fromimagesourcebuffer(com-azure-ai-vision-common-imagesourcebuffer))). For more details, see [Call the Analyze API](./call-analyze-image-40?pivots=programming-language-java#select-the-image-to-analyze).
109+
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource.fromFile](/java/api/com.azure.ai.vision.common.visionsource#com-azure-ai-vision-common-visionsource-fromfile(java-lang-string)), or by copying the image into the SDK's input buffer (see [VisionSource.fromImageSourceBuffer](/java/api/com.azure.ai.vision.common.visionsource#com-azure-ai-vision-common-visionsource-fromimagesourcebuffer(com-azure-ai-vision-common-imagesourcebuffer))). For more details, see [Call the Analyze API](./call-analyze-image-40.md?pivots=programming-language-java#select-the-image-to-analyze).
110110
111111
#### [C++](#tab/cpp)
112112

@@ -115,7 +115,7 @@ Create a new **VisionSource** object from the URL of the image you want to analy
115115
[!code-cpp[](~/azure-ai-vision-sdk/docs/learn.microsoft.com/cpp/image-analysis/how-to/how-to.cpp?name=vision_source)]
116116

117117
> [!TIP]
118-
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource::FromFile](/cpp/cognitive-services/vision/input-visionsource#fromfile)), or by copying the image into the SDK's input buffer (see [VisionSource::FromImageSourceBuffer](/cpp/cognitive-services/vision/input-visionsource#fromimagesourcebuffer)). For more details, see [Call the Analyze API](./call-analyze-image-40?pivots=programming-language-cpp#select-the-image-to-analyze).
118+
> You can also analyze a local image by passing in the full-path image file name (see [VisionSource::FromFile](/cpp/cognitive-services/vision/input-visionsource#fromfile)), or by copying the image into the SDK's input buffer (see [VisionSource::FromImageSourceBuffer](/cpp/cognitive-services/vision/input-visionsource#fromimagesourcebuffer)). For more details, see [Call the Analyze API](./call-analyze-image-40.md?pivots=programming-language-cpp#select-the-image-to-analyze).
119119
120120
#### [REST API](#tab/rest)
121121

articles/ai-services/computer-vision/includes/quickstarts-sdk/image-analysis-java-sdk-40.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ Open a console window and create a new folder for your quickstart application.
7676
</dependencies>
7777
</project>
7878
```
79-
2. Install the SDK and dependencies by running the following in the project directory:
79+
80+
1. Install the SDK and dependencies by running the following in the project directory:
8081

8182
```console
8283
mvn clean dependency:copy-dependencies
8384
```
8485

85-
3. Once the operation succeeds, verify that the folders `target\dependency` were creating and they contain `.jar` files.
86+
1. Once the operation succeeds, verify that the folders `target\dependency` were creating and they contain `.jar` files.
8687

8788
For more information, see the [SDK installation guide](../../sdk/install-sdk.md?pivots=programming-language-java).
8889

articles/ai-services/computer-vision/includes/setup-sdk/java-requirements.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@ ms.date: 08/01/2023
66
ms.author: pafarley
77
---
88

9-
The Vision SDK for C# is compatible with Windows and Linux.
9+
The Vision SDK for Java is compatible with Windows and Linux.
1010

1111
# [Windows](#tab/windows)
1212

1313
On Windows, you must use the 64-bit target architecture. Windows 10 or later is required.
1414

15-
You must install the [Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022](/cpp/windows/latest-supported-vc-redist?view=msvc-170&preserve-view=true) for your platform. Installing this package for the first time might require a restart.
15+
The Java SDK uses native binaries. You must install the [Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, and 2022](/cpp/windows/latest-supported-vc-redist?view=msvc-170&preserve-view=true) for your platform. Installing this package for the first time might require a restart.
1616

1717
# [Linux](#tab/linux)
1818

19-
The Vision SDK for C# only supports **Ubuntu 18.04/20.04/22.04** and **Debian 9/10/11** on the x64 architecture when used with Linux.
19+
The Vision SDK for Java only supports **Ubuntu 18.04/20.04/22.04** and **Debian 9/10/11** on the x64 architecture when used with Linux.
2020

2121
[!INCLUDE [Linux distributions](linux-distributions.md)]
2222

2323
---
2424

25+
## JAVA Development Kit
26+
27+
Java 8 or above is required.
28+
29+
Install a Java Development Kit (JDK) such as [Azul Zulu OpenJDK](https://www.azul.com/downloads/?package=jdk), [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk), [Oracle Java](https://www.java.com/download/), or your preferred JDK.
30+
31+
Run `java -version` from a command line to confirm successful installation and see the version. Make sure that the Java installation is native to the system architecture and not running through emulation.
32+
33+
34+

articles/ai-services/computer-vision/includes/setup-sdk/java.md

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,89 @@ ms.date: 08/01/2023
66
ms.author: pafarley
77
---
88

9-
[Reference documentation](/dotnet/api/azure.ai.vision.imageanalysis) | [Packages (NuGet)](https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis) | [Samples](https://github.com/Azure-Samples/azure-ai-vision-sdk)
9+
[Reference documentation](/java/api/com.azure.ai.vision.imageanalysis) | [Maven Package](https://mvnrepository.com/artifact/com.azure/azure-ai-vision-imageanalysis) | [Samples](https://github.com/Azure-Samples/azure-ai-vision-sdk)
1010

11-
This guide shows how to install the Vision SDK for C#.
11+
This guide shows how to install the Vision SDK for Java.
1212

1313
## Platform requirements
1414

15-
[!INCLUDE [Requirements](csharp-requirements.md)]
16-
17-
## Install the Vision SDK for C#
18-
19-
The Vision SDK for C# is available as a NuGet package and implements .NET Standard 2.0. For more information, see <a href="https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis" target="_blank">Azure.AI.Vision.ImageAnalysis</a>.
20-
21-
22-
# [Terminal](#tab/dotnetcli)
23-
24-
The Vision SDK for C# can be installed from the [.NET CLI](https://dotnet.microsoft.com/download/dotnet/). To add a package reference in your project file, run this command in the folder where your `.csproj` file is located:
25-
26-
```dotnetcli
27-
dotnet add package Azure.AI.Vision.ImageAnalysis --prerelease
15+
[!INCLUDE [Requirements](java-requirements.md)]
16+
17+
## Install the Vision SDK for Java
18+
19+
The Vision SDK for Java is available as a Maven package. For more information, see <a href="https://www.nuget.org/packages/Azure.AI.Vision.ImageAnalysis" target="_blank">Azure.AI.Vision.ImageAnalysis</a>.
20+
21+
22+
# [Maven](#tab/maven)
23+
24+
## Apache Maven
25+
26+
Follow these steps to install the Azure AI Vision SDK for Java using Apache Maven:
27+
28+
1. Install [Apache Maven](https://maven.apache.org/download.cgi). On Linux, install from the distribution repositories if available.
29+
30+
1. Open a command prompt and run `mvn -v` to confirm successful installation.
31+
32+
1. Open a command prompt where you want to place the new project, and create a new pom.xml file.
33+
34+
1. Copy the following XML content into pom.xml
35+
36+
```xml
37+
<project xmlns="http://maven.apache.org/POM/4.0.0"
38+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
39+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
40+
<modelVersion>4.0.0</modelVersion>
41+
<groupId>azure.ai.vision.imageanalysis.samples</groupId>
42+
<artifactId>image-analysis-quickstart</artifactId>
43+
<version>0.0</version>
44+
<dependencies>
45+
<!-- https://mvnrepository.com/artifact/com.azure/azure-ai-vision-imageanalysis -->
46+
<dependency>
47+
<groupId>com.azure</groupId>
48+
<artifactId>azure-ai-vision-imageanalysis</artifactId>
49+
<version>0.15.1-beta.1</version>
50+
</dependency>
51+
<!-- https://mvnrepository.com/artifact/com.azure/azure-core-http-netty -->
52+
<dependency>
53+
<groupId>com.azure</groupId>
54+
<artifactId>azure-core-http-netty</artifactId>
55+
<version>1.13.6</version>
56+
</dependency>
57+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
58+
<dependency>
59+
<groupId>org.slf4j</groupId>
60+
<artifactId>slf4j-api</artifactId>
61+
<version>2.0.7</version>
62+
</dependency>
63+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
64+
<dependency>
65+
<groupId>org.slf4j</groupId>
66+
<artifactId>slf4j-simple</artifactId>
67+
<version>2.0.7</version>
68+
</dependency>
69+
</dependencies>
70+
</project>
71+
```
72+
73+
1. Update the version value in `<version>0.15.1-beta.1</version>` based on the latest version you find in the [Maven repository](https://mvnrepository.com/artifact/com.azure/azure-ai-vision-imageanalysis).
74+
75+
1. Run the following Maven command to install the Vision SDK and dependencies.
76+
```console
77+
mvn clean dependency:copy-dependencies
2878
```
2979

30-
# [PowerShell](#tab/powershell)
31-
32-
The Vision SDK for C# can be installed from the [.NET CLI](https://dotnet.microsoft.com/download/dotnet/). To add a package reference in your project file, run this command in the folder where your `.csproj` file is located:
3380

34-
```powershell
35-
Install-Package Azure.AI.Vision.ImageAnalysis --prerelease
36-
```
81+
# [Gradle](#tab/gradle)
3782

38-
# [Visual Studio](#tab/vs)
39-
40-
Open Visual Studio and create a new application project. Then install the client SDK by right-clicking on the project solution in the **Solution Explorer** and selecting **Manage NuGet Packages**. In the package manager that opens select **Browse**, check **Include prerelease**, and search for `Azure.AI.Vision.ImageAnalysis`. Select **Install**.
83+
Gradle configurations require an explicit reference to the .jar dependency extension:
84+
```gradle
85+
// build.gradle
4186
87+
dependencies {
88+
implementation group: 'com.azure', name: ' azure-ai-vision-imageanalysis', version: "0.15.1-beta.1", ext: "jar"
89+
}
90+
```
4291

92+
Update the version number based on the latest version you find in the [Maven repository](https://mvnrepository.com/artifact/com.azure/azure-ai-vision-imageanalysis).
4393

4494
---

0 commit comments

Comments
 (0)