IDEA导出JAR包

Posted Sakurakann

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IDEA导出JAR包相关的知识,希望对你有一定的参考价值。

进入Project Structure > Artifacts -- 添加 > JAR > From modules with dependencies.... 

 

导出为可执行JAR需要设置Main Class,作为JAR程序入口.

一般工具JAR可以不设置Main Class.

 

选择extract to the target JAR 会将所有buildpath中的JAR引用都打在一个JAR中

选择copt to the output directory and link via manifest会按照.MF文件中自定义的格式来打包

 

 .MF完整示例

Manifest-Version: 1.0
Class-Path: jcl-over-slf4j-1.7.13.jar jackson-databind-2.8.0.jar sprin
 g-data-commons-1.11.4.RELEASE.jar spring-expression-4.0.4.RELEASE.jar
  junit-3.8.1.jar spring-tx-4.0.4.RELEASE.jar commons-beanutils-1.8.3.
 jar mybatis-spring-1.2.2.jar ojdbc14-10.2.0.1.0.jar itext-2.1.7.jar j
 ackson-mapper-asl-1.9.13.jar spring-beans-4.0.4.RELEASE.jar commons-l
 ogging-1.2.jar commons-dbcp-1.4.jar freemarker-2.3.20.jar mybatis-3.2
 .8.jar jsf-impl-1.2_04.jar spring-aop-4.0.4.RELEASE.jar log4j-1.2.17.
 jar druid-1.0.23.jar spring-context-support-4.1.6.RELEASE.jar commons
 -collections-3.2.1.jar aopalliance-1.0.jar ehcache-core-2.6.8.jar bcm
 ail-jdk14-138.jar jackson-annotations-2.8.0.jar mybatis-ehcache-1.0.3
 .jar spring-core-4.1.4.RELEASE.jar commons-fileupload-1.2.2.jar poi.j
 ar jstl-1.2.jar itext-2.1.7.jar junit-3.8.1.jar druid-1.0.23.jar log4
 j-1.2.17.jar mybatis-3.2.8.jar commons-io-2.4.jar fastjson-1.2.3.jar 
 itextpdf-5.5.4.jar jsf-api-1.2_04.jar aopalliance-1.0.jar jsf-impl-1.
 2_04.jar bcmail-jdk14-138.jar bcprov-jdk14-138.jar bctsp-jdk14-1.38.j
 ar commons-dbcp-1.4.jar slf4j-api-1.7.13.jar bcmail-jdk14-1.38.jar bc
 prov-jdk14-1.38.jar commons-lang3-3.4.jar freemarker-2.3.20.jar commo
 ns-pool-1.5.4.jar ehcache-core-2.6.8.jar jackson-core-2.8.0.jar ojdbc
 14-10.2.0.1.0.jar aspectjweaver-1.8.4.jar commons-logging-1.2.jar myb
 atis-spring-1.2.2.jar jcl-over-slf4j-1.7.13.jar mybatis-ehcache-1.0.3
 .jar jackson-databind-2.8.0.jar commons-beanutils-1.8.3.jar jackson-c
 ore-asl-1.9.13.jar javax.servlet-api-3.0.1.jar spring-tx-4.0.4.RELEAS
 E.jar commons-fileupload-1.2.2.jar spring-aop-4.0.4.RELEASE.jar sprin
 g-web-4.0.4.RELEASE.jar commons-collections-3.2.1.jar jackson-annotat
 ions-2.8.0.jar jackson-mapper-asl-1.9.13.jar spring-core-4.1.4.RELEAS
 E.jar spring-jdbc-4.0.4.RELEASE.jar spring-test-4.0.4.RELEASE.jar spr
 ing-beans-4.0.4.RELEASE.jar spring-webmvc-4.0.4.RELEASE.jar spring-co
 ntext-4.0.4.RELEASE.jar spring-expression-4.0.4.RELEASE.jar spring-da
 ta-commons-1.11.4.RELEASE.jar spring-context-support-4.1.6.RELEASE.ja
 r itextpdf-5.5.4.jar commons-lang3-3.4.jar bctsp-jdk14-1.38.jar jstl-
 1.2.jar bcprov-jdk14-138.jar spring-jdbc-4.0.4.RELEASE.jar spring-web
 -4.0.4.RELEASE.jar poi.jar spring-webmvc-4.0.4.RELEASE.jar bcmail-jdk
 14-1.38.jar javax.servlet-api-3.0.1.jar jsf-api-1.2_04.jar commons-po
 ol-1.5.4.jar bcprov-jdk14-1.38.jar fastjson-1.2.3.jar jackson-core-2.
 8.0.jar slf4j-api-1.7.13.jar commons-io-2.4.jar spring-test-4.0.4.REL
 EASE.jar jackson-core-asl-1.9.13.jar aspectjweaver-1.8.4.jar spring-c
 ontext-4.0.4.RELEASE.jar
Main-Class: 

 配置好后,通过 Build > Build Artifacts 选择配置的JAR, build\\rebuild;JAR文件会被创建在输出文件夹中.

 

以上是关于IDEA导出JAR包的主要内容,如果未能解决你的问题,请参考以下文章

idea如何导出jar包

idea怎么导出Maven依赖的jar包

idea怎么写一个modle导出成jar给别人用

android studio怎么导出jar包

IDEA导出JAR包

android studio怎么导出jar包