how to create jar of java package in intelliJ idea

荒凉一梦 提交于 2019-12-24 02:32:31

问题


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.

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?


回答1:


Intellij IDEA 2016.3


  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. In the IDEA Top Menu: Build -> Build Artifacts... -> select your artifact -> Build.

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



来源:https://stackoverflow.com/questions/41397753/how-to-create-jar-of-java-package-in-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!