我有一个使用java连接到localhost的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)

我try 了各种方法来解决这个问题,比如:

export DISPLAY=:10.0
export DISPLAY=localhost:10.0

我也try 了端口0.0,但总是出现同样的错误

在try xhost之后

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

我该怎么解决这个问题

我的系统是Ubuntu server edition 10.04

推荐答案

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

export DISPLAY=:0

Linux相关问答推荐

将UTC字符串日期时间转换为毫秒UTC时间戳

在Linix&;Mac中运行Reaction本机项目时出现问题

如何检测文件系统是否支持权限?

用户作用域在Linux内核密钥环(Golang)中是什么意思?

如何在bash中用另一个整数变量增加一个整数变量?

如何使用 awk 重新排列列?

sed 根据文件中的条件进行多次替换

如何使用 __attribute__((visibility("default")))?

如何在python中检索进程开始时间(或正常运行时间)

为什么在编译 K&R2 第 1 章中最长的行示例时出现getline 的类型冲突错误?

哪个程序在给定任何文件的情况下创建一个 C 数组?

无法创建Java虚拟机

将 bash 脚本添加到路径

如何在 Linux 上传递带感叹号的参数?

在 Emacs 中匹配括号的命令是什么?

给定一个 linux 用户名和密码,我如何测试它是否是有效帐户?

在 bash 中将输出作为 cp 的参数传递

解压tar tar.bz2 文件报错

crt1.o:在函数_start中:-Linux 中未定义对main的引用

如何为 Git 命令设置自动完成功能?