如何为用Java编写的程序创建可执行文件?
大家好,如何在Eclipse Helios中为Java编写的程序创建可执行文件?我的意思是创建小图标,以便仅通过双击其图标即可启动程序,提前致谢 已编辑 我的意思是 Windows 的可执行文件
everyone, how can I create executable file for the program written on Java in Eclipse Helios? I mean to create small icon to be able start program only by double-clicking on its icon, thanks in advance
edited
I mean executable for Windows
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这是一个向您展示如何从 eclipse 制作 jar 文件的教程。
如果计算机上安装了 Java,则可以通过双击 jar 文件来执行应用程序:
http: //ecs.victoria.ac.nz/Courses/COMP205_2009T1/TutorialEclipseExportToJar
Here is a tutorial that shows you how to make a jar file from eclipse.
If Java is installed on the computer, you can execute your application by doubleclicking the jar file:
http://ecs.victoria.ac.nz/Courses/COMP205_2009T1/TutorialEclipseExportToJar
你没有提到你用的是什么平台。我能想到的有两种方法。
最简单的方法是创建一个包含
java YourApp
命令行的 *.bat 文件(在 Windows 中)。如果您想创建更奇特的安装程序和可执行文件,可以使用 NSIS 脚本来执行此操作。由于您使用的是 eclipse,请考虑尝试 EclipseNSIS 生成 NSIS 脚本,这更快更容易而不是自己从头开始编写。
You didn't mention what platform you are using. There are 2 ways I can think of.
The easiest way is for you to create a *.bat file (in Windows) that contains the
java YourApp
command line.If you want to create a more fancy installer and executable, you can use NSIS script to do so. Since you are using eclipse, consider trying EclipseNSIS to generate the NSIS script, which is much faster and easier than writing it yourself from ground up.
对于这种情况,最好的答案是启动该应用程序。使用 Java Web Start。 JWS 不仅可以创建桌面和开始菜单启动项,还提供自动更新、跨平台兼容性等等。
The best answer for this situation is to launch the app. using Java Web Start. JWS can not only create desktop and start menu launch items, but provides automatic updates, cross-platform compatibility and much more.
创建一个 1 行元文件来指定 JVM 应查找哪个类来从 main(String[]) 方法开始。
运行命令 jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]
您有可执行 jar 文件 - 输入“java -jar jarfileName”,或者在提示符下直接输入“jarfileName”。在 Windows 上,您还可以双击 jar 文件徽标/名称来启动它。
祝愿,- MS
PS:这里是更详细教程的链接:
http://csdl.ics.hawaii.edu/ 〜johnson/613f99/modules/04/jar-files.html
Create a 1-line metafile to specify which class the JVM should look for to start with the main(String[]) method.
Run the command jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]
You have an executable jar file - type in "java -jar jarfileName" or, directly "jarfileName" at your prompt. On windows, you can also double click on the jar file logo/name to get it started.
Good wishes, - M.S.
PS: Here is the link to a more detailed tutorial:
http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html