【问题标题】:How can I make exe-file to write text on the command line?如何使 exe 文件在命令行上写入文本?
【发布时间】:2014-07-11 09:20:10
【问题描述】:

我有 java 控制台应用程序,将文本写入命令行。当我使用 jar 文件时,它工作正常。但是当我创建 exe 文件并使用它时,应用程序不会将任何内容写入命令行。如果我在 cmd myapp.exe writeSomething > output.txt 中写入,我可以在 output.txt 中看到输出文本。 myapp.exe开始向命令行写入文本需要做什么?

我正在使用 launch4j-maven-plugin。

这是我的配置:

<plugin>
    <groupId>com.akathist.maven.plugins.launch4j</groupId>
    <artifactId>launch4j-maven-plugin</artifactId>
    <version>1.5.2</version>
    <executions>
        <execution>
            <id>l4j-clui</id>
            <phase>package</phase>
            <goals>
                <goal>launch4j</goal>
            </goals>
            <configuration>
                <headerType>gui</headerType>
....

【问题讨论】:

  • 这里的关键是什么工具以及如何创建exe文件。
  • 我用的是launch4j-maven-plugin
  • exe文件能用什么把文本写入cmd?
  • 你需要制作一个控制台exe而不是GUI exe。
  • 请出示您的launch4j配置,我的水晶球目前没有使用...

标签: java maven cmd exe launch4j


【解决方案1】:

你的 POM 文件应该包含类似

<plugin>
    <groupId>com.akathist.maven.plugins.launch4j</groupId>
    <artifactId>launch4j-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>l4j-clui</id>
            <phase>package</phase>
            <goals><goal>launch4j</goal></goals>    
            <configuration>
                <headerType>console</headerType> 
                ....
            </configuration>

&lt;headerType&gt;console&lt;/headerType&gt; 这一行是关键。

因此它会将 EXE 文件生成为控制台应用程序,而不是 GUI 应用程序。

更多详情请见https://github.com/lukaszlenart/launch4j-maven-plugin

【讨论】:

  • @user3186861 - 我的荣幸! :) 顺便说一句,下一次 - 你好奇我是如何找到答案的吗?我之前对插件一无所知。这是手册:bit.ly/1w9zNwg - 第一个链接...
猜你喜欢
  • 1970-01-01
  • 2014-02-26
  • 1970-01-01
  • 2011-01-15
  • 1970-01-01
  • 2012-06-28
  • 2015-06-23
  • 1970-01-01
  • 2011-04-17
相关资源
最近更新 更多