如何为用 Java 编写的程序创建可执行文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4765371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 07:55:29  来源:igfitidea点击:

how can I create executable file for the program written on Java?

javaexecutable

提问by rookie

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 editedI mean executable for Windows

大家,我怎样才能为在 Eclipse Helios 中用 Java 编写的程序创建可执行文件?我的意思是创建小图标以便只能通过双击其图标来启动程序,感谢提前 编辑我的意思是 Windows 的可执行文件

回答by Shaggieh

  1. Export .jar in eclipse. (how to)
  2. Use JSmooth (info)to make an .exe file. (how to)
  1. 在 Eclipse 中导出 .jar。(如何)
  2. 使用 JSmooth (info)制作一个 .exe 文件。(如何)

回答by rookie

Here is a tutorial that shows you how to make a jar file from eclipse.

这是一个教程,向您展示如何从 Eclipse 制作 jar 文件。

If Java is installed on the computer, you can execute your application by doubleclicking the jar file:

如果计算机上安装了 Java,则可以通过双击 jar 文件来执行您的应用程序:

http://ecs.victoria.ac.nz/Courses/COMP205_2009T1/TutorialEclipseExportToJar

http://ecs.victoria.ac.nz/Courses/COMP205_2009T1/TutorialEclipseExportToJar

回答by limc

You didn't mention what platform you are using. There are 2 ways I can think of.

你没有提到你使用的是什么平台。我能想到的方法有2种。

The easiest way is for you to create a *.bat file (in Windows) that contains the java YourAppcommand line.

最简单的方法是创建一个包含java YourApp命令行的 *.bat 文件(在 Windows 中)。

If you want to create a more fancy installer and executable, you can use NSISscript to do so. Since you are using eclipse, consider trying EclipseNSISto generate the NSIS script, which is much faster and easier than writing it yourself from ground up.

如果你想创建一个更漂亮的安装程序和可执行文件,你可以使用NSIS脚本来做到这一点。由于您使用的是 eclipse,请考虑尝试使用EclipseNSIS来生成 NSIS 脚本,这比自己从头开始编写要快得多且容易得多。

回答by Andrew Thompson

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.

这种情况的最佳答案是启动应用程序。使用Java Web Start。JWS 不仅可以创建桌面和开始菜单启动项,还可以提供自动更新、跨平台兼容性等等。

回答by Manidip Sengupta

  1. Create a 1-line metafile to specify which class the JVM should look for to start with the main(String[]) method.

  2. Run the command jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]

  3. 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.

  1. 创建一个 1 行元文件以指定 JVM 应查找哪个类以从 main(String[]) 方法开始。

  2. 运行命令 jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]

  3. 您有一个可执行的 jar 文件 - 在提示下输入“java -jar jarfileName”或直接输入“jarfileName”。在 Windows 上,您还可以双击 jar 文件徽标/名称以启动它。

Good wishes, - M.S.

良好的祝愿, - MS

PS: Here is the link to a more detailed tutorial: http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html

PS:这里是更详细教程的链接:http: //csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html