GOOGLE_应用程序_凭据在JAVA中不起作用

GOOGLE_应用程序_凭据在JAVA中不起作用,java,google-api,google-authentication,Java,Google Api,Google Authentication,我试着用 我在身份验证方面有很大的问题 我遵循这一点,导出GOOGLE_应用程序_凭据,并使用echo进行检查,一切正常 但当我从第一个链接开始编写代码时,我得到了一个错误: Exception in thread "main" java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Oth

我试着用

我在身份验证方面有很大的问题

我遵循这一点,导出GOOGLE_应用程序_凭据,并使用echo进行检查,一切正常

但当我从第一个链接开始编写代码时,我得到了一个错误:

Exception in thread "main" java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information.
at com.google.auth.oauth2.DefaultCredentialsProvider.getDefaultCredentials(DefaultCredentialsProvider.java:119)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:127)
at com.google.auth.oauth2.GoogleCredentials.getApplicationDefault(GoogleCredentials.java:100)
at com.google.api.gax.core.GoogleCredentialsProvider.getCredentials(GoogleCredentialsProvider.java:53)
at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:110)
at com.google.cloud.speech.v1.stub.GrpcSpeechStub.create(GrpcSpeechStub.java:93)
at com.google.cloud.speech.v1.SpeechSettings.createStub(SpeechSettings.java:128)
at com.google.cloud.speech.v1.SpeechClient.<init>(SpeechClient.java:143)
at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:125)
at com.google.cloud.speech.v1.SpeechClient.create(SpeechClient.java:117)
at com.example.speech.QuickstartSample.main(QuickstartSample.java:58)

但当我重新启动计算机并调用
stat
时,我发现
stat:缺少操作数

我的导出推荐
export GOOGLE\u APPLICATION\u CREDENTIALS=/home/kruczek/Pulpit/mirthconnection-59cb32bcd531.json
我通过IDEIntellij运行项目,在
privat static void main
旁边有绿色箭头来运行方法。

在eclipse中, 运行->运行配置..->环境选项卡

在名称下输入GOOGLE_应用程序_凭据: 在值中输入json路径:


在值中输入path时,请确保未使用引号进行输入。

能否显示导出命令以及如何运行代码?请共享
stat$GOOGLE\u APPLICATION\u凭据的输出
“但当我重新启动计算机并调用stat时,我发现stat:missing operand”-这表明您仅确保当前会话中存在环境变量。不清楚“当我开始编写代码时”是什么意思-我们不知道您是如何运行代码的。如果它在同一个会话中,则应该可以,但否则环境变量将不存在。我在IDE中运行代码,并在导出的同一个会话中运行它。我没有设置$GOOGLE\u APPLICATION\u凭据,但我有相同的结果使用方法:(最后一个)
File: /home/kruczek/Pulpit/mirthconnection-59cb32bcd531.json
Size: 2329          Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d  Inode: 2360629     Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/ kruczek)   Gid: ( 1000/ kruczek)
Access: 2017-12-01 14:20:33.111439885 +0100
Modify: 2017-12-01 14:20:33.111439885 +0100
Change: 2017-12-01 15:24:26.476545027 +0100
Birth: -