问题描述
我正在使用 PuTTY 与 Raspberry Pi 建立套接字连接.我正在开发一个电视记分牌应用程序.我正在使用 WinSCP 将那些 .sh
文件复制到 Raspberry Pi 中.
I'm using PuTTY to have the socket connection with Raspberry Pi.I'm developing a TV scoreboard application.I'm using WinSCP to copy those .sh
file into the Raspberry Pi.
当我运行一个脚本 ./timer.sh
:
#!/bin/bash
java -jar /home/pi/ScoreBoard_app/Timer/Timer.jar
显示错误:
Exception in thread "AWT-EventQueue-0" 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 javax.swing.JFrame.<init>(JFrame.java:224)
at com.javafx.main.Main$1.run(Main.java:816)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
我什至尝试设置DISPLAY=localhost:0.0
.
它将显示 X11 服务器无法在localhost:10.0"上连接的错误.
I have even tried to set the DISPLAY=localhost:0.0
.
It will show error that X11 server cannot connect on "localhost:10.0".
我也试过 localhost:1.0
,但我得到同样的错误,它无法在localhost:1.0"上连接.
I also tried localhost:1.0
, but I get the same error that it can't connect on "localhost:1.0".
推荐答案
您的 rasperry-pi 需要在 sshd_config
your rasperry-pi needs to enable X forwarding in sshd_config
你需要在你的电脑上运行一个X服务器,Xming是一个很好的开源X服务器
you need to have a X server running on your pc, Xming is a good open source X server
安装并启动Xming后,需要配置putty,设置x显示位置为localhost:0.0
after installing and starting Xming, you need to configure putty, set x display location as localhost:0.0
详情搜索xming putty rasperry pi
这篇关于Raspberry Pi:未设置 X11 DISPLAY 变量,但该程序执行了需要它的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!