0

我是 perl、python 人,是 java 和 groovy 的新手。运行 groovyConsole 时出现此错误

groovy 工作正常。

myhome:~/gscripts # groovyConsole
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:108)
    at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
Caused by: java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.

我添加了这个

DISPLAY=:0.0
export DISPLAY

到 /home/me/.bask_profile 和 /home/me/.bashrc 也不过是徒劳。帮助我,让我知道为什么会发生此错误。

4

1 回答 1

2

The groovy console is a GUI app and it looks like you're trying to run it in an environment that doesn't support graphics, e.g. connecting to a remote machine via telnet/SSH.

A possible workaround is to use the Groovy shell instead of the Groovy console. The Groovy shell is functionally similar to the Groovy console, but the shell is a command-line, rather than a GUI app.

Assuming the Groovy bin directory is on your PATH variable, you should be able to run it by typing groovysh.

于 2010-09-07T14:13:09.427 回答