双击运行 Java 应用程序
为什么我无法双击运行我的 java 编译的应用程序? 我的应用程序只是在cmd中运行(java -jar:我的app.jar) 请帮助我
why i can`t run my java compiled applications with double click?
my applicatins just run in cmd (java -jar: my app.jar)
plz help me
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以创建一个批处理文件来运行您的命令。这样它就可以工作而无需与 .jar 文件关联。如果它是 Windows 应用程序,则使用 javaw.exe 启动它。
You can make a batch file to run your command. This way it will work without the need to make associations to .jar files. If it is a windows app then start it with javaw.exe.
您需要将 .jar 扩展名与
javaw.exe
关联起来,然后双击该 jar 文件时将不会显示控制台窗口这通常是由 JDK/JRE 安装程序完成的,所以您要么没有没有正确安装 JDK,或者您手动更改了该关联。
You need to associate the .jar extension with
javaw.exe
, then no console window will be shown, when you double click the jar fileThis is usually done by the JDK/JRE installer, so either you didn't install the JDK properly, or you manually changed that associaten.
我认为这里所有的答案都是有效的。但如果您想要在 Windows 中获得真正的可执行文件,那么您需要创建一个启动器。在 Windows 中,jar 文件不可执行。但exe文件是。有很多工具可以将所有 Java 代码包装在某个本机库中。我推荐 http://launch4j.sourceforge.net/ 我认为这就是您正在寻找的。您可以轻松创建带有图标和更多功能的可执行文件。
I think all the answer here are valid. But if you want a true executable file in Windows then you need to create a launcher. In windows, jar files are not executable. But exe files are. There are many tools out there than wrap all your java code around some native library. I recommend http://launch4j.sourceforge.net/ I think this is what you are looking for. You can easily create executable with icons and many more features.
您可以创建
.jar
文件的 Windows 快捷方式。以下行可能是 Windows 快捷方式的目标。
这样做的优点是允许您指定所需的
javaw
参数,以及所需的 Windows 参数(正常窗口、最大化、在目录中启动)。You can create a Windows shortcut to your
.jar
file.The following line could be the target of the Windows shortcut.
This has the advantage of allowing you to specify the
javaw
parameters that you want, as well as the Windows parameters (normal window, maximized, start in directory) that you want.只需分配要由
javaw.exe
执行的.jar
文件即可。您可以使用.jar
文件上的打开方式
对话框来执行此操作。顺便说一句,Java 安装程序没有为您执行此操作吗?
Just assign
.jar
files to be executed byjavaw.exe
. You can do that using theOpen with
dialog on a.jar
file.BTW, doesn't the Java installer do that for you?