0

I run this /edit command in jshell java-11,When throw the exception.

Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.

I'm using Debian 9.0 operating System.

Exception image

jshell> /edit

Ng Sharma
  • 2,072
  • 8
  • 27
  • 49
  • 1
    `DISPLAY` is an environment variable used by the [X Windows System](https://en.wikipedia.org/wiki/X_Window_System). If you search the Internet for "X Windows DISPLAY environment variable", you should find how to set it. Your error message implies that your java code references classes in `java.awt` package, either directly or indirectly. Excuse me but I couldn't see your java code in your post. Did I miss something? – Abra Jul 05 '19 at 14:17
  • jshell> /edit No protocol specified Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable. – Ng Sharma Jul 05 '19 at 14:24
  • @Abra this Exception generated in jshell, not java code. – Ng Sharma Jul 05 '19 at 14:25
  • @Abra Please read the question. – Ng Sharma Jul 05 '19 at 14:31
  • The `/edit` command in _JShell_ tries to open an editor window. In order to do that it assumes that an X windows server is running. Is that the case? – Abra Jul 05 '19 at 14:39
  • Hint: cursing doesn't help and isn't appreciated here. And you still didn't tell us about your setup. Are you running some gnome or kde desktop, and have a terminal doing this, or are you ssh'ing into your machine? – GhostCat Jul 05 '19 at 15:32

1 Answers1

0

Most likely, the following things come together:

  • you are running jshell in a way that prevents it from starting/raising your preferred editor
  • that preference is determined from looking at some environment variables (see here for names/order)

Thus, a simple solution could be: set the JSHELLEDITOR environment variable to something that doesn't require a X window, like vi for example.

GhostCat
  • 137,827
  • 25
  • 176
  • 248