How do I create a runnable JAR in IntelliJ as I would in Eclipse

前端 未结 4 893
小蘑菇
小蘑菇 2020-12-01 12:10

My process for creating a runnable JAR from a project with many libraries with Eclipse has been.

Export > Runnable JAR > Select launch configuration > Packag

相关标签:
4条回答
  • 2020-12-01 12:28

    you could try using a gradle script. eclipse will make you a gradle project. you can use that build file with any ide. it has a built in jar task.

    0 讨论(0)
  • 2020-12-01 12:34

    You can these steps:

    1) File -> Project Structure -> Project Settings -> Artifacts -> Jar -> From modules with dependencies

    2) Check the Include in project build checkbox.

    3) Right mouse click on module -> build module 'ModuleName'

    0 讨论(0)
  • 2020-12-01 12:36

    You're facing two issues one seems major and one is minor:

    • Major: signature exception
    • Minor: size of the jar is 15 MB greater than the jar produced by eclipse.

    The solution of both of the issues lies in the way you are building the artifact. First of all, remove all extracted *.jar then add all the jar's from the available elements pan as shown in the figure.

    It is obvious that adding packaged(compressed) jars only, will decrease the size. But it also solves the signing issue. For more explanation, please have a look at this article. I'll only quote one line.

    It's probably best to keep the official jar as is and just add it as a dependency in the manifest file......

    It seems that some of the dependencies are signed and repackaging messes up the META-INF of your project.

    0 讨论(0)
  • 2020-12-01 12:54

    If you are using Maven you need to put META-INF directory under /main/resources folder instead of main/java.

    Reference: Intellij - Nikolay Chashnikov

    Then you can execute the runnable jar normally with java -jar filename.jar

    0 讨论(0)
提交回复
热议问题