In macOS 11.6 running this passing junit test, where Terminal and TerminalBuilder are from jline3:
@Test
void test1() throws IOException {
Terminal t = getTerminal();
Assertions.assertNotNull(t);
}
getTerminal:
public Terminal getTerminal() throws IOException {
return TerminalBuilder.terminal();
}
Alternative getTerminal:
public Terminal getTerminal() throws IOException {
return TerminalBuilder.builder().system(true).build();
}
I'm getting this warning message in the console with either version of getTerminal:
WARNING: Unable to create a system terminal, creating a dumb terminal (enable debug logging for more information)
Obviously I want a system terminal. I have both Jansi and JNA on the classpath as well as the full jline3. I tried running inside Eclipse and from the command line with maven. Results are the same.
Any suggestions on how to get a system terminal?
You need to run your app on command line in order to get system terminal because System.in
and System.out
must be attached to your console. This is not a case when you run junit test and probably neither when launching app using maven.
You should write an app and launch it using java
command in order to get system terminal.