Linux “没有 X11 显示变量” - 这是什么意思?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/662421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"No X11 DISPLAY variable" - what does it mean?
提问by user42155
I am trying to install a Java application on my Linux machine (Slackware).
我正在尝试在我的 Linux 机器(Slackware)上安装 Java 应用程序。
I have received the following error, and I do not understand it.
我收到以下错误,我不明白。
Could you advise me how to approach the problem? Thank you.
你能告诉我如何解决这个问题吗?谢谢你。
Here is what I get: (I see that some X11 DISPLAYvariable needs to be set, but what value should I give it and how?)
这是我得到的:(我看到需要设置一些X11 DISPLAY变量,但是我应该给它什么值以及如何设置?)
~$ java -jar gate-5.0-beta1-build3048-installer.jar
- ERROR -
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
java.awt.HeadlessException:
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
at java.awt.GraphicsEnvironment.checkHeadless(Graphic sEnvironment.java:159)
at java.awt.Window.<init>(Window.java:407)
at java.awt.Frame.<init>(Frame.java:402)
at net.sourceforge.mlf.metouia.borders.MetouiaDotsBuf fer.<init>(MetouiaDotsBuffer.java:105)
at net.sourceforge.mlf.metouia.borders.MetouiaDots.<i nit>(MetouiaDots.java:66)
at net.sourceforge.mlf.metouia.borders.MetouiaToolBar Border.<init>(MetouiaToolBarBorder.java:49)
at net.sourceforge.mlf.metouia.MetouiaLookAndFeel.ini tComponentDefaults(MetouiaLookAndFeel.java:241)
at javax.swing.plaf.basic.BasicLookAndFeel.getDefault s(BasicLookAndFeel.java:130)
at javax.swing.plaf.metal.MetalLookAndFeel.getDefault s(MetalLookAndFeel.java:1591)
at javax.swing.UIManager.setLookAndFeel(UIManager.jav a:537)
at javax.swing.UIManager.setLookAndFeel(UIManager.jav a:581)
at com.izforge.izpack.installer.GUIInstaller.loadLook AndFeel(GUIInstaller.java:373)
at com.izforge.izpack.installer.GUIInstaller.<init>(G UIInstaller.java:116)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:30
at com.izforge.izpack.installer.Installer.main(Instal ler.java:62)
采纳答案by Paul Tomblin
If you're on the main display, then
如果您在主显示屏上,则
export DISPLAY=:0.0
or if you're using csh or tcsh
或者如果您使用的是 csh 或 tcsh
setenv DISPLAY :0.0
before running your app.
在运行您的应用程序之前。
Actually, I'm surprised it isn't set automatically. Are you trying to start this application from a non-graphic terminal? If not, have you modified the default .profile, .login, .bashrc or .cshrc?
实际上,我很惊讶它没有自动设置。您是否尝试从非图形终端启动此应用程序?如果没有,您是否修改了默认的 .profile、.login、.bashrc 或 .cshrc?
Note that setting the DISPLAY to :0.0 pre-supposes that you're sitting at the main display, as I said, or at least that the main display is logged on to your user id. If it's not logged on, or it's a different userid, this will fail.
请注意,将 DISPLAY 设置为 :0.0 预先假设您坐在主显示器上,正如我所说,或者至少主显示器已登录到您的用户 ID。如果它没有登录,或者它是一个不同的用户 ID,这将失败。
If you're coming in from another machine, and you're at the main display of that machine and it's running X, then you can use "ssh -X hostname" to connect to that host, and ssh will forward the X display back. ssh will also make sure that the DISPLAY environment variable is set correctly (providing it isn't being messed with in the various dot files I mentioned above). In a "ssh -X" session, the DISPLAY environment variable will have a value like "localhost:11.0", which will point to the socket that ssh is tunnelling to your local box.
如果您从另一台机器进入,并且您在该机器的主显示器上并且它正在运行 X,那么您可以使用“ssh -X 主机名”连接到该主机,并且 ssh 会将 X 显示转发回来. ssh 还将确保正确设置 DISPLAY 环境变量(前提是它没有被我上面提到的各种点文件弄乱)。在“ssh -X”会话中,DISPLAY 环境变量将具有类似于“localhost:11.0”的值,该值将指向 ssh 正在通过隧道传输到本地机器的套接字。
回答by Mikeage
Are you running this from within an X11 environment? You can use a terminal window, but it has to be within X (either after a graphical login, or by running startx).
您是在 X11 环境中运行它吗?您可以使用终端窗口,但它必须在 X 内(在图形登录后或通过运行 startx)。
If you're already within a graphical environment, try export DISPLAY=:0 for bash like shells (bash, sh, etc) or setenv DISPLAY :0 for C shell based shells (csh, tcsh, etc)
如果您已经在图形环境中,请尝试 export DISPLAY=:0 用于 bash 之类的 shell(bash、sh 等)或 setenv DISPLAY :0 用于基于 C shell 的 shell(csh、tcsh 等)
If you've connected from another machine via SSH, you use the -X option to display the graphical interface on the machine you're sitting at (provided there's an X server running there (such as xming for windows, and your standard Linux X server).
如果您通过 SSH 从另一台机器连接,您可以使用 -X 选项在您所在的机器上显示图形界面(假设有一个 X 服务器在那里运行(例如 Windows 的 xming,以及您的标准 Linux X服务器)。
回答by Tihamer
Don't forget to execute "host +" on your "home" display machine, and when you ssh to the machine you're doing "ssh -x hostname"
不要忘记在你的“home”显示机器上执行“host +”,当你ssh到机器时你正在做“ssh -x hostname”
回答by victe
I have had the same issue in Ubuntu 14.04.01 when I tried to install JDK 8 and Netbeans if I launch the script inside a Byobu terminal (maybe with Screens happens the same).
我在 Ubuntu 14.04.01 中遇到了同样的问题,当我尝试安装 JDK 8 和 Netbeans 时,如果我在 Byobu 终端中启动脚本(也许 Screens 也会发生同样的情况)。
Just exit Byobu and (in a graphical terminal) run the script.
只需退出 Byobu 并(在图形终端中)运行脚本。
回答by Kanagavelu Sugumar
Initial Check.
初步检查。
1) When you are exporting the DISPLAY to other machine, ensure you entered the command xhost +
on that machine. This command allows to other machine to export their DISPLAY on this machine. There may be security constraints, just know about it. Need to check ssh -X MachineIP
will not require xhost +
?
1) 当您将 DISPLAY 导出到其他机器时,请确保您xhost +
在该机器上输入了命令。该命令允许其他机器在这台机器上导出他们的 DISPLAY。可能存在安全限制,了解一下即可。需要检查ssh -X MachineIP
就不需要xhost +
?
2) Some times JCONSOLE
won't show all its process, since those JVM process may run with different user and you are exporting the DISPLAY with another user. so better follow CD_DIR>sudo ./jconsole
2) 有时JCONSOLE
不会显示其所有进程,因为这些 JVM 进程可能与不同的用户一起运行,而您正在与另一个用户一起导出 DISPLAY。所以最好跟随CD_DIR>sudo ./jconsole
3) In WAS (WEBSPHERE); jconsole won't be able to connect its java server process, that time just go till the link, then try connecting it. This worked for me. May be this page is initializing some variables to enable jconsole to connect with that server.
3) 在 WAS (WEBSPHERE) 中;jconsole 将无法连接它的 java 服务器进程,那个时候只需转到链接,然后尝试连接它。这对我有用。可能是这个页面正在初始化一些变量以使 jconsole 能够与该服务器连接。
WAS console > Application servers > server1 > Process definition > Java Virtual Machine
WAS 控制台 > 应用服务器 > server1 > 流程定义 > Java 虚拟机
I have faced the same issue with AIX (where command line interface only available, There is no DISPLAY UI) machine. I resolved by installing
我在 AIX(仅提供命令行界面,没有 DISPLAY UI)机器上遇到了同样的问题。我通过安装解决了
NX Client for Windows
适用于 Windows 的 NX 客户端
Step 1: Through that Windows machine, I connected with unix box where GUI console is available.
Step 2: SSH to the AIX box from that UNIX box.
Step 3: set DISPLAY like "export DISPLAY=UNIXMACHINE:NXClientPORTConnectedMentionedOnTitle"
Step 4: Now if we launch any programs which requires DISPLAY; it will be launched on this UNIX box.
第 1 步:通过那台 Windows 机器,我连接了可以使用 GUI 控制台的 unix box。
第 2 步:从那个 UNIX 机器通过 SSH 连接到 AIX 机器。
第 3 步:将 DISPLAY 设置为“export DISPLAY=UNIXMACHINE:NXClientPORTConnectedMentionedOnTitle”
第 4 步:现在如果我们启动任何需要 DISPLAY 的程序;它将在这个 UNIX 机器上启动。
VNC
虚拟网络
If you installed VNC on UNIX box where display is available; then Windows and NX Client is not required.
Step 1: Use VNC to connect with Unix box where GUI console is available.
Step 2: SSH to the AIX box from that UNIX box.
Step 3: set DISPLAY like "export DISPLAY=UNIXMACHINE:VNCPORT"
Step 4: Now if we launch any programs which requires DISPLAY; it will be launched on this UNIX box.
如果您在可以显示的 UNIX 机器上安装了 VNC;则不需要 Windows 和 NX 客户端。步骤 1:使用 VNC 连接有 GUI 控制台的 Unix box。
第 2 步:从那个 UNIX 机器通过 SSH 连接到 AIX 机器。
第 3 步:将 DISPLAY 设置为“export DISPLAY=UNIXMACHINE:VNCPORT”
第 4 步:现在如果我们启动任何需要 DISPLAY 的程序;它将在这个 UNIX 机器上启动。
ELSE
别的
Step 1: SSH to the AIX box from that UNIX box.
Step 2: set DISPLAY like "export DISPLAY=UNIXMACHINE:VNCPORT"
Step 3: Now if we launch any programs which requires DISPLAY; it will be launched on this UNIX box.
步骤 1:从那个 UNIX 机器通过 SSH 连接到 AIX 机器。
第 2 步:将 DISPLAY 设置为“export DISPLAY=UNIXMACHINE:VNCPORT”
第 3 步:现在如果我们启动任何需要 DISPLAY 的程序;它将在这个 UNIX 机器上启动。
回答by Арсений Пичугин
One more thing that might be the problem in a case similar to described - X is not forwarded and $DISPLAY is not set when 'xauth' program is not installed on the remote side. You can see it searches for it when you run "ssh -Xv ip_address", and, if not found, fails, which's not seen unless you turn on verbose mode (a fail IMO). You can usually find 'xauth' in a package with the same name.
在与所描述的情况类似的情况下,还有一件事可能是问题 - 当远程端未安装“xauth”程序时,X 未转发且 $DISPLAY 未设置。当您运行“ssh -Xv ip_address”时,您可以看到它在搜索它,如果找不到,则失败,除非您打开详细模式(IMO 失败),否则不会看到它。您通常可以在同名的包中找到“xauth”。
回答by Peter Azuka Molokwu
Very Easy, Had this same problem then what i did was to download and install an app that would help in displaying then fixed the error.
很简单,遇到了同样的问题,然后我所做的是下载并安装一个有助于显示的应用程序,然后修复错误。
Download this app xming:
下载此应用程序 xming:
http://sourceforge.net/project/downloading.php?
http://sourceforge.net/project/downloading.php?
Install, then use settings on this link:
安装,然后使用此链接上的设置:
http://www.geo.mtu.edu/geoschem/docs/putty_install.htmlor follow this steps:
http://www.geo.mtu.edu/geoschem/docs/putty_install.html或按照以下步骤操作:
Installing/Configuring PuTTy and Xming
安装/配置 PuTTy 和 Xming
Once PuTTy and Xming have been downloaded to the PC, install according to their respective instructions.
将 PuTTy 和 Xming 下载到 PC 后,按照各自的说明进行安装。
Configuring Xming
配置 Xming
Once Xming is installed, run the application called 'XLaunch' and verify that the settings are as shown:
安装 Xming 后,运行名为“XLaunch”的应用程序并验证设置是否如图所示:
- select Default entries on Display Settings windows, click next
- click next on Session Type window.
- click next on Additional parameters window(Notice clipboard checkbox is true)
- save configuration and click to finish.
- 在“显示设置”窗口中选择“默认条目”,单击“下一步”
- 在会话类型窗口中单击下一步。
- 单击“附加参数”窗口上的下一步(注意剪贴板复选框为真)
- 保存配置并单击完成。
Configuring PuTTy
配置腻子
After installing PuTTy, double-click on the PuTTy icon on the desktop and configure as shown:
安装PuTTy后,双击桌面上的PuTTy图标,配置如图:
This shows creating a login profile then saving it.
这显示了创建登录配置文件然后保存它。
- On ssh -> X11, click on checkbox to enable X11 forwarding.
- on X display location textbox, type localhost:0.0
- 在 ssh -> X11 上,单击复选框以启用 X11 转发。
- 在 X 显示位置文本框中,输入 localhost:0.0
save profile then connect remotely to server to test.
保存配置文件,然后远程连接到服务器进行测试。
Cheers!!!
干杯!!!
回答by Girdhar Singh Rathore
you must enable X11 forwardingin you PuTTy
您必须在 PuTTy 中启用X11 转发
to do so open PuTTy, go to Connection => SSH => Tunnelsand check mark the Enable X11 forwarding
为此,请打开 PuTTy,转到Connection => SSH => Tunnels并选中Enable X11 forwarding
Also sudo to server and export the below variable here IP is your local machine's IP
还要 sudo 到服务器并导出以下变量,这里的 IP 是您本地机器的 IP
export DISPLAY=10.75.75.75:0.0
回答by Subramaniam Ramasubramanian
For those who are trying to get an X Window application working from Windows from Linux:
对于那些试图从 Linux 的 Windows 获取 X Window 应用程序的人:
What worked for me was to setup xming server on my windows machine, set X11 forwarding option in putty when I connect to the linux host and put in my windows ip address with the display port and then the display variable with my windows IP address:0.0
对我有用的是在我的 Windows 机器上设置 xming 服务器,当我连接到 linux 主机时在 putty 中设置 X11 转发选项并使用显示端口输入我的 Windows ip 地址,然后使用我的 Windows IP 地址输入显示变量:0.0
Dont forget to add the linux hosts IP address to the X0.hosts file to ensure that the xming server accepts traffic from that host. Took me a while to figure that out.
不要忘记将 linux 主机 IP 地址添加到 X0.hosts 文件以确保 xming 服务器接受来自该主机的流量。我花了一段时间才弄清楚。
回答by Naseer-shaik
There are many ways to do this. I did something below convenient to me and always works fine.
有很多方法可以做到这一点。我做了以下对我来说方便的事情,并且总是工作正常。
- On your remote server, make sure to install xorg-x11-xauth, xorg-x11-font-utils, xorg-x11-fonts.
- Run the Xming Server on you local desktop
- On putty, before ssh to the server, enable the X11 forwarding and set the display location to localhost:0.0
On the server, .Xauthority file is generated and notice that the DISPLAY variable is already set.
$ xauth list
$ xauth add
- 在您的远程服务器上,确保安装 xorg-x11-xauth、xorg-x11-font-utils、xorg-x11-fonts。
- 在本地桌面上运行 Xming Server
- 在putty上,ssh到服务器之前,开启X11转发,设置显示位置为localhost:0.0
在服务器上,生成 .Xauthority 文件并注意 DISPLAY 变量已经设置。
$ xauth 列表
$ xauth 添加
To test it, type xclock or xeyes
要测试它,请键入 xclock 或 xeyes
Note: To switch user, copy the .Xauthority file to the home directory of the respective user and also export the DISPLAY variable from that user.
注意:要切换用户,请将 .Xauthority 文件复制到相应用户的主目录,并从该用户导出 DISPLAY 变量。