Launch4J可执行文件未按预期执行 [英] Launch4J executable not executing as expected

查看:179
本文介绍了Launch4J可执行文件未按预期执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

工具: Win 7,Launch4J 3.5,简单的Hello world Java控制台应用程序(捆绑在JAR文件中)

Tools: Win 7, Launch4J 3.5, Simple Hello world Java console app (bundled in a JAR file)

大家好,

我有一个基本的JAVA控制台应用程序,它不要求任何输入,只是一个简单的应用程序,它可以打开控制台窗口并显示Hello World文本.

I have a basic JAVA console application that doesn't request any inputs, just a simple application that opens a console window and displays Hello World text.

我构建起来非常简单,因此我可以尝试使用Launch4J 3.5并从jar文件中构建可执行文件.

I built it so simple so I can experiment with Launch4J 3.5 and build an executable file from the jar file.

一切看起来都很好,exe能够成功构建,但是当我启动它时,什么也没发生,我得到了几秒钟的沙漏,然后什么也没有.我检查了任务管理器,发现那里没有进程.

Everything looks fine, the exe builds successfully but when I launch it nothing happens, I get the hour glass for a few seconds then nothing. I check the Task Manager and there's no process stuck in there.

请参阅我在Launch4J中的设置,我只填写了基础知识,我尝试在包装器清单字段中输入和不输入:

See my settings in Launch4J, I only filled in the basics, I tried with and without an entry in the Wrapper manifest field:

输出文件::C:\ Development \ SFDC \ ProjectX \ out \ exe \ ProjectX.exe

Output file: C:\Development\SFDC\ProjectX\out\exe\ProjectX.exe

Jar: C:\ Development \ SFDC \ ProjectX \ out \ artifacts \ ProjectX_jar \ ProjectX.jar

Jar: C:\Development\SFDC\ProjectX\out\artifacts\ProjectX_jar\ProjectX.jar

包装清单: C:\ Launch4j \ manifest \ uac.exe.manifest(也尝试将其留空)

Wrapper manifest: C:\Launch4j\manifest\uac.exe.manifest (also tried with leaving this blank)

其余的都保留为默认值.

推荐答案

如果通过启动表示双击,则不会-您将看不到任何东西.您必须讲" Java才能通过关联的控制台运行您的应用程序.为此,您可以创建一个新的.bat文件:只需打开文本编辑器并插入以下行:

If by launching you mean double clicking it, no - nothing you can see will happen; you have to 'tell' Java to run your application with an associated console. To do this, you may create a new .bat file: Simply open a text editor and insert the following line:

java -jar NAME.jar

其中"NAME"是您的应用程序的名称.以.bat格式而不是.txt格式保存文本文件,并将其放置在与应用程序相同的目录中.您可以通过双击该文件来启动应用程序.

where "NAME" is the name of your application. Save the text file in .bat format, not in .txt, and place it in the same directory as your application. You can launch your application by double-clicking that file.

它没有在任务管理器中弹出的原因是,可能(我不知道)您的应用程序仅打印出一条简单的消息而无所作为.在非控制台模式下,由于没有控制台可以打印消息,因此它将仅调用您的print(println或任何其他控制台)方法而没有任何视觉效果.但是,在这两种情况下,如果您仅打印某些内容而没有执行其他最后的"操作(例如侦听输入),则您的程序将在到达main方法的末尾时终止.

The reason it does not pop up in your task manager is because probably (I cannot know) your application only prints out a simple message and does nothing more. In non-console mode, it will just call your print (println or any other console) method without having any visual effect as there is no console to print the message to. In both cases however, if you only print something and do not perform other operations that 'last', such as listening for input, your programm will terminate as it has reached the end of the main method.

这篇关于Launch4J可执行文件未按预期执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆