创建jar文件最简单的方法? [英] The simplest way to create jar file?

查看:122
本文介绍了创建jar文件最简单的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个java项目,我需要从我的项目中创建jar文件。任何机构都可以告诉我最简单的方法是什么?

I have a java project and i need to create jar file from my project . any body can tell me what is the simplest way to make this?

推荐答案

从头开始..用CMD

命令行几乎是所有其他应用程序将用于构建 JAR 文件的内容。他们只是为你包装好一点。事实上,做自己很简单。显然 Java已经详细解释了这一点所以没有在我的意义重复它。

The command line is what almost every other application will use to build your JAR file. They just wrap it up a little nicer for you. In truth, it's very simple to do yourself. Obviously Java have explained this way in detail so there is no sense in me repeating it.

注意:你需要将 JDK / bin directoy附加到你的%PATH%系统变量可以使用此方法。

Note: You need to have your JDK/bin directoy appended onto your %PATH% system variable to be able to use this method.

Double Note :正如评论中指出的那样,我建议你继续尝试这种方法,直到你明白它为止。让这些东西处于较低水平非常重要,因此如果IDE出现问题,您可以更好地理解如何解决它。

Double Note: As pointed out in the comments, I'd suggest you keep trying this method until you understand it. It is very important that you get these things at a low level, so if something goes wrong with the IDE, you have a much better understanding of how to solve it.

Eclipse

Eclipse为它提供了一个很好的界面。你可以找到一步一步的教程这里。它的长短是..

Eclipse offers a nice interface for it. You can find a step by step tutorial here. The long and short of it is..

Right click on Project -> Export -> JAR File -> Select the Java files to include

完成此操作后,点击完成而你是金色的。本教程还添加了一些额外的提示,使其尽可能无缝。

When you've done this, hit finish and you're golden. The tutorial also adds some additional tips in to make it as seamless as possible.

IntelliJ IDEA

我个人最喜欢的IDE。 这个问题提供了一个很好的解释如何导出为JAR文件。再次,它的长短......

My personal favourite IDE. This question offers a nice explanation for how to export as a JAR file. Again, the long and short of it..

File -> Project Structure -> Artifacts

然后,您可以点击 +创建新工件图标。这将为您提供文件类型的选项,即 .JAR 以及要包含在工件中的模块。当你完成后,你去... ..

In there, you can then create a new artifact by clicking the + icon. This will give you an option for the file type, which is .JAR and which modules you want to include in your artifact. When you're done, you go to..

Build -> Build Artifacts

它将创建 JAR 来自你项目的文件。

And it will create the JAR file from your project.

使用Maven

我经常发现这个是一个非常棒的工具,绝对值得考虑。在IntelliJ中,双击生命周期中的安装过程..

I've often found this to be a pretty awesome tool, and definitely one worth considering. In IntelliJ, by double clicking the install procedure in the life cycles..

这将创建一个新的 JAR .target 目录中的文件。

This will create a new JAR file in your .target directory.

注意 :某些IDE(如IntelliJ)默认会隐藏 .target 目录。确保在项目设置中显示它。

Note: Some IDEs (like IntelliJ) will hide the .target directory by default. Make sure you make it visible in the project settings.

这篇关于创建jar文件最简单的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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