gpt4 book ai didi

java - 使用 Java 在终端中编译 Google Cloud 库时出现获取包不存在错误

转载 作者:行者123 更新时间:2023-12-01 17:00:32 24 4
gpt4 key购买 nike

我在 src/下有一个 java 文件,该文件具有以下导入内容,因为我想使用 Google Cloud 的翻译 API:

import com.google.cloud.translate.*;

我的 main 方法在 Main.java 中。我将所有必需的 .jar 文件存储在名为“Cloud”的文件夹中,在终端中,我尝试通过运行来编译代码:

$ javac -cp "Cloud/*.jar" src/*.java

但我收到以下错误:

src/Main.java:4: error: package com.google.cloud.translate does not exist
import com.google.cloud.translate.*;
^

我不知道为什么,因为我导入了所有依赖项并设置了类路径。当我在 IDE Eclipse 中运行程序时一切正常,但当我尝试在终端中编译它时却不起作用。有什么想法吗?

最佳答案

我将发布我的评论作为答案,因为它对于评论部分来说太长了。

检查 official documentation regarding the Translating API 时,在尝试使用它之前已声明遵循 Translation Quickstart Using Client Libraries对于设置过程,因为它可能会有所帮助。

此外,我偶然发现了 this SO post表明问题可能在于在 src 文件夹之外运行 javac 命令。

我希望这些信息有帮助。

关于java - 使用 Java 在终端中编译 Google Cloud 库时出现获取包不存在错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61511462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com