从 Eclipse 生成可执行文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4518637/
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
Generating an executable file from Eclipse
提问by Gondim
I've made a program to help me out with some stuff, but every time I need it, I open Eclipse and Run it.
我已经制作了一个程序来帮助我解决一些问题,但是每次我需要它时,我都会打开 Eclipse 并运行它。
Is it possible to create an executable file so I won't need to open Eclipse every time? The commands I use is basically System.out.println() and Scanner to read what I type.
是否可以创建一个可执行文件,这样我就不需要每次都打开 Eclipse?我使用的命令基本上是 System.out.println() 和 Scanner 来读取我输入的内容。
回答by Cratylus
Right-click on project.
Export as runnable jar.
右键单击项目。
导出为可运行的 jar。
回答by Serplat
File -> Export -> Java -> Runnable JAR File
File -> Export -> Java -> Runnable JAR File
You'll have to choose the main class that you want it to run. This will allow you to double-click on the JAR, and have it run that main.
您必须选择希望它运行的主类。这将允许您双击 JAR,并让它运行该主文件。
回答by dimitrisli
You can File > Export > JAR file
to export your project as a jar and put the java command to run the jar on a windows batch file. Alternatively you can File > Export > Runnable JAR file
您可以File > Export > JAR file
将项目导出为 jar 并在 Windows 批处理文件中使用 java 命令来运行 jar。或者你可以File > Export > Runnable JAR file
回答by slartidan
You can either create an executable jar file (using eclipse, or a build tool like "ant" or "maven") or you can also create a "real" Windows-executable file (which you can also give to customers/friends).
您可以创建一个可执行的 jar 文件(使用 eclipse,或者像“ant”或“maven”这样的构建工具),也可以创建一个“真正的”Windows 可执行文件(您也可以将其提供给客户/朋友)。
I am using JSmooth a lot ( http://jsmooth.sourceforge.net/) - this builds a wrapper around your jar-files and can help the user with downloading and installing an appropriate java virtual machine version.
我经常使用 JSmooth ( http://jsmooth.sourceforge.net/) - 这会围绕您的 jar 文件构建一个包装器,并可以帮助用户下载和安装适当的 Java 虚拟机版本。
Probably the executable jar (see answer of Serplat) file is what you need :)
可能是您需要的可执行 jar(请参阅 Serplat 的答案)文件:)