繁体   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?

我正在Google App Engine Flex环境上运行一个应用程序(播放框架),该应用程序正试图从Google云端硬盘下载文件。 当我尝试下载代码时,出现以下错误:

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)

我发现了一些有关正在发生的事情的帖子,但对Google App Engine Flex and Play Framework没什么帮助:

“没有X11 DISPLAY变量”-这是什么意思?

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

这是我正在使用的代码:

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();
    }
}

来自这篇文章:

如何使用Java中的Google Drive API库强制从Google Team Drive下载文件

我从这篇文章中看到,我可能需要设置一个变量DISPLAY=0:0

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

如何在Play Framework应用程序中设置此变量,或者如何在Google App Engine Flex实例上进行设置?

感谢您的帮助。

您可以在App Engine flexible中设置环境变量 因此,根据您的情况,尝试像这样编辑app.yaml文件:

env_variables:
    DISPLAY=0.0

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM