简体   繁体   English

运行Play Framework应用程序但未获得X11 DISPLAY变量的Google App Engine Flex设置错误; 在哪里设置此变量?

[英]Google App Engine Flex on running Play Framework app getting No X11 DISPLAY variable was set error ; where do I set this variable?

I am running an application (Play Framework) on the Google App Engine Flex environment, that is trying to download a file from the Google Drive. 我正在Google App Engine Flex环境上运行一个应用程序(播放框架),该应用程序正试图从Google云端硬盘下载文件。 When I attempt to download the code, I receive this error: 当我尝试下载代码时,出现以下错误:

java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.Desktop.getDesktop(Desktop.java:142)

I found a few posts on what is happening but nothing to help me with the Google App Engine Flex and Play Framework: 我发现了一些有关正在发生的事情的帖子,但对Google App Engine Flex and Play Framework没什么帮助:

"No X11 DISPLAY variable" - what does it mean? “没有X11 DISPLAY变量”-这是什么意思?

Start X server on Google Cloud (Debian) Compute Engine 在Google Cloud(Debian)Compute Engine上启动X服务器

Here is my code that I am using: 这是我正在使用的代码:

public static void downloadFile(String fileID) {
    // Set the drive service...
    Drive service = null;
    try {
        service = getDriveService();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        Desktop desktop = java.awt.Desktop.getDesktop();
        // place your webContentLink in the oURL variable
        URI oURL = new URI("https://drive.google.com/a/google.com/uc?id=" + fileID + "&export=download");
        desktop.browse(oURL);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

which came from this post: 来自这篇文章:

How to force download of file from Google Team Drive using Google Drive API libraries in Java 如何使用Java中的Google Drive API库强制从Google Team Drive下载文件

I see that, from this post, that I may need to set a variable DISPLAY=0:0 : 我从这篇文章中看到,我可能需要设置一个变量DISPLAY=0:0

https://superuser.com/questions/1223939/no-x11-display-variable-was-set-but-this-program-performed-an-operation-which-r https://superuser.com/questions/1223939/no-x11-display-variable-was-set-but-this-program-performed-an-operation-which-r

How do I set this variable inside the Play Framework application or can I set on the Google App Engine Flex instance? 如何在Play Framework应用程序中设置此变量,或者如何在Google App Engine Flex实例上进行设置?

I appreciate the help. 感谢您的帮助。

You can set environment variables in App Engine flexible. 您可以在App Engine flexible中设置环境变量 So, in your case, try to edit your app.yaml file like this: 因此,根据您的情况,尝试像这样编辑app.yaml文件:

env_variables:
    DISPLAY=0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获得 HeadlessException:未设置 X11 DISPLAY 变量 - Getting a HeadlessException: No X11 DISPLAY variable was set 在Mac上未设置X11 DISPLAY变量 - No X11 DISPLAY variable was set on Mac 没有设置X11 DISPLAY变量 - No X11 DISPLAY variable was set 仅当通过ant运行时,没有X11显示变量设置错误 - No X11 Display variable set error only when running through ant 如何设置“X11 DISPLAY variable was set”? - How to set “X11 DISPLAY variable was set”? Ubuntu Libgdx 问题 - 未设置 X11 DISPLAY 变量 - Ubuntu Libgdx problem - No X11 DISPLAY variable was set 设置了Linux Java程序X11 DISPLAY变量,但是 - Linux Java program X11 DISPLAY variable was set, but 尝试运行jar文件时获取“未设置X11 DISPLAY变量” - Getting “No X11 DISPLAY variable was set” while trying to run jar file 获取“未设置X11 DISPLAY变量,但是该程序执行了需要它的操作。” - Getting “ No X11 DISPLAY variable was set, but this program performed an operation which requires it.” “没有设置X11显示变量,但是该程序执行了需要它的操作”错误含义是什么?如何/可以解决该问题? - What does “no X11 display variable was set, but this program performs an operation which requires it” error mean and how/can I fix it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM