当我启动 cygwin/XX Server (1.17.1-2),然后启用 x11 转发的 putty(X 显示位置设置为localhost:10.0
并勾选 MIT-Magic-Cookie-1)时,我仍然收到错误
Startup Error: Unable to detect graphics environment
当我尝试启动任何程序(例如pycharm)时。无论是在我的 Windows 机器上,还是在我的 Linux 机器上,我都没有DISPLAY
设置变量。当我将鼠标悬停在 Windows 托盘中的 cygwin 图标上时,它会显示cygwin x server :0.0
,因此我export DISPLAY=:0.0
在 Windows 和 Linux 机器上都进行了尝试。但后来我明白了
Start Failed: Failed to initialize graphics environment
java.awt.AWTError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:115)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:103)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:128)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.awt.Toolkit$2.run(Toolkit.java:860)
at java.awt.Toolkit$2.run(Toolkit.java:855)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:854)
at com.intellij.ui.AppUIUtil.updateFrameClass(AppUIUtil.java:155)
at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:94)
at com.intellij.idea.MainImpl.start(MainImpl.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.ide.plugins.PluginManager.lambda$start$0(PluginManager.java:75)
at java.lang.Thread.run(Thread.java:745)
我尝试了各种组合(DISPLAY=:0
)来去除X display location
腻子,但没有帮助
设置:
- Linux 盒子是一个
Red Hat Enterprise Linux Server release 6.6 (Santiago)
- Windows 是 Windows 7 企业版 64 位
- Putty 版本 0.68 发布编译器:Visual Studio 2015 / MSVC++ 14.0 (_MSC_VER=1900)
谢谢
答案1
您需要使用选项启动 startxwin -listen
。例如我的快捷方式是:
C:\cygwin64\bin\run.exe --quote /usr/bin/bash.exe -l -c "cd; exec /usr/bin/startxwin -- -listen tcp"
https://sourceware.org/ml/cygwin-announce/2015-04/msg00050.html
“-nolisten tcp”现在是默认值,因此服务器仅接受 unix 域套接字上的本地连接。添加了“-listen”选项,可用于恢复以前的行为。