[英]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.