如何通过双击图标执行JAVA程序? [英] How to execute JAVA program by double clicking on icon?

查看:146
本文介绍了如何通过双击图标执行JAVA程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个java程序。现在我想打开我的控制台java应用程序没有IDE,Eclipse等,但只需双击桌面上的可执行文件。



我已经导出了java项目在Runnable .JAR文件中,但无法打开。当我试图使用cmd打开应用程序。 java -jar ApplicatonName.jar和一切都很好。但是这个过程太复杂了,它不是用户友好的。



所以有什么可能的方式用JAVA做这样的事情?



提前感谢:)

解决方案

创建一个 bat sh 文件,具体取决于操作系统,并在该文件中放入 java -jar ApplicationName.jar



您可以双击该文件启动应用程序。



Windows示例:



创建一个文件 MyProgram.bat 。在文本编辑器中打开文件。添加 java -jar MyApplicationName.jar (以应用程序名称/ jar的名称替换MyApplicationName)。保存文件。双击创建的文件打开你的程序。


I have written a java program. Now I would like to open my console java application without IDE, Eclipse etc., but just by double clicking on the executable version on my Desktop.

I have exported the java project in Runnable .JAR file, but it cannot be opened. When I tried to open the application with cmd. java -jar ApplicatonName.jar and everything is fine. But this process is too complicated, and it's not user-friendly.

So is there any possible way to do such thing with JAVA ?

Thanks in advance :)

解决方案

Create a bat or sh file, depending on the operating system, and put java -jar ApplicationName.jar in that file.

You can double click on that file to launch your application.

Example for Windows:

Create a file MyProgram.bat. Open the file in a text editor. Add java -jar MyApplicationName.jar (replace MyApplicationName by the name of your application/the name of the jar). Save the file. Double click the created file to open your program.

这篇关于如何通过双击图标执行JAVA程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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