简体   繁体   中英

Jline3 Issues with Windows Terminal

So I just set up a Jline3 Project in my IDE to try out if it works.

It has only one class, which I copied from here: https://github.com/jline/jline3/blob/master/builtins/src/test/java/org/jline/example/Example.java

Jline3 provides some nice features which I actually want to use, even though the documentation is quite poor. Problem being; it does not work on windows. It works flawlessy with a mac terminal, on centos and even in the git bash on windows (mingw).

However, if I execute my jar in a windows terminal or cmder, it'll throw an warning and none of the completers will work.

WARNING: unable to create a system terminal, creating dumb terminal (enable debug logging for more information)

My pom looks like this:

<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>jline3Test</groupId>
<artifactId>jline3-test</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <configuration>
                <createDependencyReducedPom>true</createDependencyReducedPom>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <excludes>META_INF/*.SF</excludes>
                            <excludes>META_INF/*.DSA</excludes>
                            <excludes>META_INF/*.RSA</excludes>
                        </excludes>
                    </filter>
                </filters>
                <transformers>
                    <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                    <transformer
                            implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>Application</mainClass>
                    </transformer>
                </transformers>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    </plugins>
</build>

<dependencies>
    <dependency>
        <groupId>org.jline</groupId>
        <artifactId>jline</artifactId>
        <version>3.8.0</version>
    </dependency>
</dependencies>

Questions:

  • Does anyone know how to enable debug logging and redirect the logs to system.out?

  • Has anyone had the same issue and knows how to fix it?

thanks in advance

You need to have either jna ( https://mvnrepository.com/artifact/net.java.dev.jna/jna ) or jansi ( https://mvnrepository.com/artifact/org.fusesource.jansi/jansi ) on the classpath.

Having that you need either jline-terminal-jansi ( https://mvnrepository.com/artifact/org.jline/jline-terminal-jansi ) or jline-terminal-jna (https://mvnrepository.com/artifact/org.jline/jline-terminal-jna ), which integrate these with JLine3.

So you can chose whether to use jansi or jna, but you must have the 2 libraries for the according. Hope that helps.

Find this also directly in the Jline3 Documentation: https://github.com/jline/jline3#jansi-vs-jna

Best, Mark

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM