当前位置: 首页 > 面试题库 >

Java无法使用'localhost:10.0'作为DISPLAY变量的值连接到X11窗口服务器

邹高峻
2023-03-14
问题内容

我有一个脚本使用Java连接到本地主机的端口10.0中显示X11

但是我总是得到这个错误

java.lang.InternalError: Can't connect to X11 window server using 'localhost:10.0' as the value of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:62)
    at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:178)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:142)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:82)
    at sun.awt.X11.XToolkit.<clinit>(XToolkit.java:112)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:186)
    at java.awt.Toolkit$2.run(Toolkit.java:849)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:841)
    at ij.io.Opener.openJpegOrGif(Opener.java:367)
    at ij.io.Opener.openImage(Opener.java:220)
    at ij.io.Opener.openImage(Opener.java:249)
    at ij.io.Opener.open(Opener.java:116)
    at ij.IJ.open(IJ.java:1112)
    at ij.macro.Functions.open(Functions.java:2006)
    at ij.macro.Functions.doFunction(Functions.java:129)
    at ij.macro.Interpreter.doStatement(Interpreter.java:205)
    at ij.macro.Interpreter.doBlock(Interpreter.java:515)
    at ij.macro.Interpreter.runUserFunction(Interpreter.java:278)
    at ij.macro.Interpreter.getFactor(Interpreter.java:1200)
    at ij.macro.Interpreter.getTerm(Interpreter.java:1162)
    at ij.macro.Interpreter.getExpression(Interpreter.java:1145)
    at ij.macro.Interpreter.getBooleanExpression(Interpreter.java:881)
    at ij.macro.Interpreter.getLogicalExpression(Interpreter.java:857)
    at ij.macro.Interpreter.getBoolean(Interpreter.java:850)
    at ij.macro.Interpreter.doIf(Interpreter.java:829)
    at ij.macro.Interpreter.doStatement(Interpreter.java:217)
    at ij.macro.Interpreter.doBlock(Interpreter.java:515)
    at ij.macro.Interpreter.doStatement(Interpreter.java:241)
    at ij.macro.Interpreter.doIf(Interpreter.java:831)
    at ij.macro.Interpreter.doStatement(Interpreter.java:217)
    at ij.macro.Interpreter.doStatements(Interpreter.java:195)
    at ij.macro.Interpreter.run(Interpreter.java:99)
    at ij.macro.Interpreter.run(Interpreter.java:65)
    at ij.macro.Interpreter.run(Interpreter.java:75)
    at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:127)
    at ij.plugin.Macro_Runner.runMacroFile(Macro_Runner.java:112)
    at ij.IJ.runMacroFile(IJ.java:103)
    at ij.ImageJ.main(ImageJ.java:517)

我已经尽力解决这个问题,例如:

export DISPLAY=:10.0
export DISPLAY=localhost:10.0

我也尝试了端口0.0,但总是得到相同的错误

尝试xhost之后

xhost +local:all
xhost:  unable to open display ""
xhost:  unable to open display ":10.0"

我该如何解决这个问题,我认为X Server没有运行,所以我尝试了startx它说在该端口运行

我的系统是Ubuntu服务器版本10.04


问题答案:

这个命令帮助我解决了这个问题:

export DISPLAY=:0


 类似资料:
  • 我有2个应用程序工作良好,除了生产环境中的一个功能。此功能是从一个简单的表生成excel。在我的所有其他环境中,生成excel是可以的,但当我试图在生产环境中使用它时。我有这个错误在日志和一个可怕的错误500在我的应用程序! 我能找到什么线索吗?我已经比较了我所有的java版本。就像我在使用weblogic服务器一样,我的所有java版本都是一样的。 我正在使用Apache的API(用于生成exc

  • 我正在尝试使用 javamail 连接到本地后缀鸽子服务器。我已经使用 Thunderbird 成功连接到服务器,所以我知道我的用户名和密码是正确的,但我总是得到 我所知道的唯一一件事就是改变java。禁用一些不太安全的协议。dovecot需要什么协议?还是我看错了方向。 如果这是一个协议问题,是否有任何方法可以将参数传递给编译器?我确实有其他服务,我想阻止支持禁用的协议 编辑: 这是我使用的代码

  • 问题内容: 当我尝试使用PHP发送电子邮件时,我一直收到此错误消息: 我的php.ini看起来像这样: 我将笔记本电脑用作服务器。.我在做什么错?谢谢。 问题答案: 您需要在本地运行邮件服务器。如果是Unix,请启用sendmail。如果是Windows,请安装IIs的“简单邮​​件传输服务器”(不确定名称是否正确)组件。

  • null ...9200/_cluster/nodes ...9200/_cluster/health?pretty=true Java代码: Java版本: 问题已按以下方式解决。确保您的客户端和服务器版本是同步的!

  • 这是mysql连接php脚本。它不断地显示出它的错误 警告:mysqli_connect():(HY000/1045):用户'user'@'localhost'(使用密码:YES)在第6行的C:\xampp\htdocs\index.php访问被拒绝 注意:尝试在第7行连接成功的C:\xampp\htdocs\index.php中获取非对象的属性 我听不懂,请帮帮我好吗?

  • 首先,我知道有很多类似的问题,但我所看到的似乎都不能解决我的设置(我发现的任何解决方案都不管用)。所以请容忍我。。。 我的服务器主机名是IP地址,而不是域名(即URL看起来像:) 我的服务器有一个真正的证书(即,没有自签名) 我的应用程序的plist条目字典为空(没有任何例外-出厂设置ATS) 这是生产代码,我不能禁用ATS(我也不认为我可以,因为例外只适用于显式域名,而不是IP地址) (iOS9