简体   繁体   中英

Exporting individual packages to a jar - IntelliJ IDEA 10.5.2

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.

为要成为单独jar的每个包/类集创建单独的模块(右键单击项目,然后单击New-> Module)。

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.

eg You only want to export "mypackage" which is situated in "project/src/mainpackage/anotherpackage/mypackage"

you go into "anotherpackage" and run the following command.

jar cvf myjar.jar mypackage/

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 ie .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(ie compiled files) for such use.

你可以通过安装Handy Export Jar插件快速导出你想要导出的jar包。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM