问题
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
- 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
- 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