8

I am using Jline2 framework to build a console application in Java. When launching the application from Eclipse on Windows 7, the shell exists immediately and does not wait for the user to input commands.

Any idea on what might be wrong?

sangupta
  • 2,396
  • 3
  • 23
  • 37

2 Answers2

16

Finally found a small trick to make it work. Add the following VM option to the execution parameters (Run Config/Debug Config)

-Djline.terminal=jline.UnsupportedTerminal

This will make the code run inside Eclipse. However, some strange characters may be written to the console during the course of the run.

Hope this helps.

sangupta
  • 2,396
  • 3
  • 23
  • 37
  • This definitely helps :) Even the code completion doesn't work, I can at least develop in Eclipse. Thanks. – Thomas Uhrig Apr 23 '14 at 10:11
  • @Thomas Uhrig Did you get any result to fix code completion problem? – Alex Feb 17 '15 at 21:40
  • @Alex No, unfortunately not. The problem is, that the Eclipse console is not a "real" console. It's just a widget inside Eclipse and it's not as powerful as a real console would be. I don't think it could work... – Thomas Uhrig Feb 18 '15 at 09:12
0

If you are using picocli with jline2.

You can delegate the heuristic to picocli which seems better than the jline2 heuristic (instead of using -Djline.terminal=jline.UnsupportedTerminal)

The code can looks like :

// JLine 2 does not detect some terminal as not ANSI compatible, like Eclipse Console
// see : https://github.com/jline/jline2/issues/185
// So use picocli heuristic instead :
if (!Help.Ansi.AUTO.enabled() && //
          Configuration.getString(TerminalFactory.JLINE_TERMINAL, TerminalFactory.AUTO).toLowerCase()
                 .equals(TerminalFactory.AUTO)) {

     TerminalFactory.configure(TerminalFactory.NONE);
}

(see https://github.com/jline/jline2/issues/185)

sbernard
  • 444
  • 3
  • 16