如何在intelliJ想法中创建Java包的jar [英] how to create jar of java package in intelliJ idea
本文介绍了如何在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
- 文件->项目结构...
- 项目设置->左栏中的工件 中间列中的
- "+"-> JAR->空->输入名称
- 在中间列中单击创建的名称
- 输出布局(右列)->"+"(添加副本)->目录内容 如果您的.class文件位于com.myprojects.myfirstproject中,则应在jar的根目录中创建"com"文件夹,在"com"文件夹中创建"myprojects"文件夹,在"myprojects"文件夹中创建"myfirstproject"
- "+"->文件->从com.myprojects.myfirstproject中选择.class文件
- 在jar的根目录中创建清单文件
- 将Main Class指定为"com.myprojects.myfirstproject.Main"
- 应用
- File -> Project Structure...
- Project Settings -> Artifact in the left column
- "+" in the middle column -> JAR -> Empty -> Type name
- Click the created Name in the middle column
- 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
- "+" -> File -> select your .class files from com.myprojects.myfirstproject
- Create Manifest File in the root of jar
- Specify Main Class as "com.myprojects.myfirstproject.Main"
- Apply
- 在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屋!
查看全文