![](/img/trans.png)
[英]Getting a HeadlessException: No X11 DISPLAY variable was set
[英]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沒什么幫助:
在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
:
如何在Play Framework應用程序中設置此變量,或者如何在Google App Engine Flex實例上進行設置?
感謝您的幫助。
您可以在App Engine flexible中設置環境變量 。 因此,根據您的情況,嘗試像這樣編輯app.yaml
文件:
env_variables:
DISPLAY=0.0
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.