如何在intelliJ想法中创建Java包的jar [英] how to create jar of java package in intelliJ idea

查看:51
本文介绍了如何在intelliJ想法中创建Java包的jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用模块内部的包中的编译类创建一个jar.我有一个jar文件,它实际上是模块内部的一个包,我需要重新创建它.

I need to create a jar with compiled classes from a package which is inside of the module. I have a jar file which is actually a package inside of the module and I need to re-create it.

我可以创建整个模块的jar,但是无法创建包的jar文件.我该如何做到这一点?

I can create jar of the whole module but I could not create the jar file of the package. How can I do that on idea?

推荐答案

Intellij IDEA 2016.3

Intellij IDEA 2016.3

  1. 文件->项目结构...
  2. 项目设置->左栏中的工件
  3. 中间列中的
  4. "+"-> JAR->空->输入名称
  5. 在中间列中单击创建的名称
  6. 输出布局(右列)->"+"(添加副本)->目录内容 如果您的.class文件位于com.myprojects.myfirstproject中,则应在jar的根目录中创建"com"文件夹,在"com"文件夹中创建"myprojects"文件夹,在"myprojects"文件夹中创建"myfirstproject"
  7. "+"->文件->从com.myprojects.myfirstproject中选择.class文件
  8. 在jar的根目录中创建清单文件
  9. 将Main Class指定为"com.myprojects.myfirstproject.Main"
  10. 应用
  1. File -> Project Structure...
  2. Project Settings -> Artifact in the left column
  3. "+" in the middle column -> JAR -> Empty -> Type name
  4. Click the created Name in the middle column
  5. Output Layout (right column) -> "+" (Add Copy of) -> Directory Content If your .class file is in com.myprojects.myfirstproject you should create "com" folder in the root of jar, "myprojects" folder in the "com" folder, "myfirstproject" in the "myprojects" folder
  6. "+" -> File -> select your .class files from com.myprojects.myfirstproject
  7. Create Manifest File in the root of jar
  8. Specify Main Class as "com.myprojects.myfirstproject.Main"
  9. Apply


  1. 在IDEA顶部菜单中:Build-> Build Artifacts ...->选择您的工件-> Build.


您可以在步骤3中指定的Output目录中找到创建的工件.


You can find the created artifact in the Output directory specified on the step 3.

这篇关于如何在intelliJ想法中创建Java包的jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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