将单个包导出到 jar - IntelliJ IDEA 10.5.2
有谁知道如何使用 IntelliJ IDEA 10.5.2 将单个包/类文件导出到 jar 中,而不是导出整个项目?
谢谢。
Does anyone know how I can export individual packages/class files into a jar with IntelliJ IDEA 10.5.2 instead of exporting the whole project?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为您想要成为单独 jar 的每个包/类集创建单独的模块(右键单击项目,然后新建 -> 模块)。
Create separate module (right click on the project, then New -> Module) for each packages/classes set you want to be a separate jar.
对于任何来这里寻求答案的人:
您可以使用命令行制作 jar。您所要做的就是在要导出为 jar 的包的父文件夹中运行该命令。
例如,您只想导出位于“project/src/mainpackage/anotherpackage/mypackage”中的“mypackage”,
您进入“anotherpackage”并运行以下命令。
有关 jar 命令的更多信息,请查看文档: https://docs.oracle.com/javase/tutorial/deployment/jar/build.html
注意:
如果您仅制作源文件的 jar,即.java 文件在 src 文件夹内,您将无法将其用作其他项目中的库。
请务必制作一个 .class 文件(即编译文件)的 jar 以供此类使用。
For anyone who comes here for the answer:
You can make the jar using the command line. All you have to do is, run the command in the parent folder of the package you want to export as jar.
e.g You only want to export "mypackage" which is situated in "project/src/mainpackage/anotherpackage/mypackage"
you go into "anotherpackage" and run the following command.
for more information on the jar command, take a look at the documentation: https://docs.oracle.com/javase/tutorial/deployment/jar/build.html
NOTE:
if you make a jar of only the source files i.e. .java files inside the src folder, you won't be able to use it as a library in other projects.
Be sure to make a jar of the .class files(i.e. compiled files) for such use.
您可以通过安装Handy Export Jar插件来快速导出想要导出的jar包。
You can quickly export the jar package you want to export by installing the Handy Export Jar plug-in.