【问题标题】:Jline3 Issues with Windows TerminalWindows 终端的 Jline3 问题
【发布时间】:2018-10-17 09:12:11
【问题描述】:

所以我只是在我的 IDE 中设置了一个 Jline3 项目来尝试它是否有效。

它只有一个类,我从这里复制的:https://github.com/jline/jline3/blob/master/builtins/src/test/java/org/jline/example/Example.java

Jline3 提供了一些我真正想使用的不错的功能,尽管文档很差。问题是;它不适用于 Windows。它可以在 mac 终端、centos 甚至 windows (mingw) 上的 git bash 中完美运行。

但是,如果我在 windows 终端或 cmder 中执行我的 jar,它会抛出一个警告,并且没有一个完成者将工作。

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

我的 pom 看起来像这样:

<?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>

问题:

  • 有谁知道如何启用调试日志并将日志重定向到 system.out?

  • 有没有人遇到过同样的问题并知道如何解决?

提前致谢

【问题讨论】:

    标签: java maven jar jline3


    【解决方案1】:

    您需要在类路径中包含 jna (https://mvnrepository.com/artifact/net.java.dev.jna/jna) 或 jansi (https://mvnrepository.com/artifact/org.fusesource.jansi/jansi)。

    如果您需要 jline-terminal-jansi (https://mvnrepository.com/artifact/org.jline/jline-terminal-jansi) 或 jline-terminal-jna (https://mvnrepository.com/artifact/org.jline/jline-terminal-jna),它们与 JLine3 集成。

    所以你可以选择是使用 jansi 还是 jna,但是你必须有 2 个库。希望对您有所帮助。

    也可以直接在 Jline3 文档中找到这个:https://github.com/jline/jline3#jansi-vs-jna

    最好, 标记

    【讨论】:

    • 非常感谢您的回复,马克。可悲的是,这会在 windows 下产生一个可怕的错误终端。
    猜你喜欢
    • 1970-01-01
    • 2018-11-17
    • 2021-11-13
    • 1970-01-01
    • 1970-01-01
    • 2020-12-09
    • 1970-01-01
    • 1970-01-01
    • 2016-04-12
    相关资源
    最近更新 更多