提问人:Ethan 提问时间:11/16/2023 最后编辑:Ethan 更新时间:11/16/2023 访问量:62
线程“main”java.awt.AWTError中的异常:无法使用“0.0”作为DISPLAY变量的值连接到X11窗口服务器
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using '0.0' as the value of the DISPLAY variable
问:
我正在通过此处找到的教程来构建测试模拟。我正在使用 WSL,因此我将 XMing 用于我的 GUI。当我运行时,我收到此错误:我想要的结果是在运行时 GUI 打开。这是我当前正在使用的教程的页面。trick-dre
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using '0.0' as the value of the DISPLAY variable.
trick-dre &
我尝试过的解决方案:
sudo trick-dre &
没有给我错误,但没有出现 GUI。unset DISPLAY
执行时出现错误Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
trick-dre
我使用 -ac 选项运行 Xming:,这会打开 Xming 的物理窗口,但它是空白的,而不是预期的 GUI。
Xming -ac
我确保我的 Windows 防火墙允许 Xming。是的。
重新启动 WSL 并重新启动 Xming。
设置为我的 IP 地址而不是“0.0”,这给了我
DISPLAY
0:0
Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using <ipaddress>:0 as the value of the DISPLAY variable.
我试过了,但它给了我
xhost +
xhost: unable to open display "0.0"
将 设置为 会产生与解决方案 6 相同的错误。
DISPLAY
localhost:0
我还确保 Xming 正在运行。
我没有使用远程主机,只是使用本地环境,因此我认为不需要 ssh 转发。
注意:显然我无法进入无头模式,因为我需要 GUI。这些解决方案是我在其他线程上发现的类似问题的十几个相关解决方案的最终结果。
答:
您的解决方案 6 描述暗示您使用命令“export DISPLAY=0:0”?
您是否尝试过“export DISPLAY=:0.0”?我认为:0.0是启用UI显示的标准方式。
如果需要向其他用户 su 操作,请确保在 su 之前以登录用户身份执行 “xhost +”。
评论
xhost +
xhost: unable to open display "0.0"
评论