双击使可执行的JAR在控制台中运行 [英] Make an executeble JAR run in a console when double clicked

查看:118
本文介绍了双击使可执行的JAR在控制台中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将用C ++编写的简单控制台应用程序移植到Java,以显示语言的相似程度以及如何移植代码.我已经使用Eclipse导出了程序的可执行JAR.当使用java -jar命令运行这些JAR时,它们可以正常工作.但是,从Windows资源管理器(双击)执行它们时,它们不能正常运行.控制台窗口可以快速打开和关闭.

I'm in the process of porting simple console apps written in C++ to Java in order to show how similar the languages are, and how code can be ported. I've exported executable JARs for the programs using Eclipse. These JARs work fine when they are run using the java -jar command. However, they do not run properly when executed from windows explorer (double clicked). A console window simply opens and closes rapidly.

到目前为止,我发现的唯一解决方案是使用批处理文件.还有其他选择吗?

The only solution I have found thus far is to use a batch file. Is there any other option?

推荐答案

使用批处理文件似乎是我最好的选择.我想这就是Eclipse具有启动器的原因.

Using a batch file seems to be my best option. I suppose that's why Eclipse has a launcher.

这篇关于双击使可执行的JAR在控制台中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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