You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Eclipse中使用Java测试Google Cloud Vision的JAR包获取问题

Hey there! I’ve been stuck trying to get Google Cloud Vision working in Eclipse without build tools before—let me share exactly how to fix this, either by going the Maven route (which you’re already considering, smart move!) or even the manual JAR way if you really need it.

How to Get Google Cloud Vision Java Code Compiling in Eclipse

This is the easiest way since it handles all JAR downloads and dependency management automatically:

  • Create a new Maven project in Eclipse
    Go to File > New > Maven Project, check "Create a simple project" (skip archetype selection if you don’t need it), fill in your Group Id and Artifact Id, then finish.
  • Add the Cloud Vision dependency to pom.xml
    Open the pom.xml file in your new project, find the <dependencies> section (add it if it doesn’t exist), and paste this:
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud-vision</artifactId>
      <version>2.32.0</version> <!-- Grab the latest version from Maven Central if needed -->
    </dependency>
    
    Save the file, and Eclipse will automatically pull down all required JARs (including nested dependencies like Google Auth, gRPC, etc.)—no manual downloading required!
  • Move your existing code into the Maven project
    Maven expects Java code in src/main/java—create a package structure matching your test class, then copy your Cloud Vision code into the correct directory. Adjust the package declaration in your Java file to match.
  • Set up your service account key
    Don’t forget to add your Google Cloud service account JSON key to the project, and point to it in your code:
    System.setProperty("GOOGLE_APPLICATION_CREDENTIALS", "src/main/resources/your-service-key.json");
    
    (Pro tip: Put the key in src/main/resources so it’s included in the build path automatically.)

If you really don’t want to use Maven, you’ll need to download all required JARs manually. But fair warning—this is error-prone because Cloud Vision has dozens of dependencies. Here’s the gist:

  1. Search for google-cloud-vision on Maven Central, download the main JAR file.
  2. Check the "Dependencies" tab for that artifact, then download every single listed JAR (including transitive dependencies that those JARs rely on).
  3. In Eclipse, right-click your project > Build Path > Add External Archives, and select all the downloaded JARs.
    Again, this is messy—version conflicts are super likely, so stick with Maven if you can.

内容的提问来源于stack exchange,提问作者gordon613

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 04:34:24