[英]How to build an executable jar file with Ant
I'm developing Swing
based application in Java
I want a executable JAR file for this project. 我正在用
Java
开发基于Swing
的应用程序,我想要该项目的可执行JAR文件。
All external library files used in the project should be packaged in the JAR file. 项目中使用的所有外部库文件都应打包在JAR文件中。
How can I build a runnable JAR file using ANT? 如何使用ANT构建可运行的JAR文件?
but it needs all external library files used in the project should be along with the jar.
但它需要项目中使用的所有外部库文件都应与jar一起使用。
Of course, but the external JARS should not be bundled in with the executable JAR. 当然,但是外部JARS不应与可执行JAR捆绑在一起。
You need to do three things: 您需要做三件事:
You give clients the ZIP. 您给客户邮递区号。 They unpack it and execute your executable JAR.
他们解压缩并执行您的可执行JAR。
You need to include the manifest
task in your jar
task. 您需要将
manifest
任务包括在jar
任务中。 The manifest references the main class to be executed by default when you start your jar. 清单在启动jar时引用要默认执行的主类。
it could look like this : 它可能看起来像这样:
<jar...
<manifest file="MANIFEST.MF">
<attribute name="Main-Class" value="com.example.YourMainClass"/>
</manifest>
</jar>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.