获取"没有设置X11 DISPLAY变量"在尝试运行jar文件时

时间:2016-05-13 15:01:48

标签: java amazon-web-services x11 putty x11-forwarding

我试图通过Putty运行一个jar文件,这是通过Amazon Web Server上传的。我试图将编译器合规性级别从1.8更改为1.7。我收到错误:

Exception in thread "main" java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:207)
        at java.awt.Window.<init>(Window.java:535)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.JFrame.<init>(JFrame.java:174)
        at Smiley.<init>(Smiley.java:10)
        at Main.main(Main.java:5)

I've enabled X11 forwarding in Putty

当我从桌面运行时,jar文件工作正常。

1 个答案:

答案 0 :(得分:1)

您需要确保AWS服务器上安装了一些基本的X11软件包。特别是,您需要xhostxorg-x11-xauth计划。使用Amazon Linux,安装xorg-x11-server-utilsUncaught Error: Actions must be plain objects. Use custom middleware for async actions.软件包。