How do I create a Netbeans style Jar with all dependencies in a lib folder?

The Coordinator

As the question says, how to package a Netbeans Maven project exactly the way a Netbeans native project is packaged:

  • All the dependencies in a separate lib folder
  • The main project jar with a manifest that includes the lib folder on it's classpath
The Coordinator

In your pom.xml file ...

1) Add this code to your project->properties node. This will define your main class in a central place for use in many plugins.

<properties>
        <mainClass>project.Main.class</mainClass>
</properties>

2) Add this code to your project->build->plugins node. It will collect all your jar dependencies into a lib folder AND compile your main class jar with the proper classpath reference:

    <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
            <execution>
                <phase>install</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                    <classpathPrefix>lib/</classpathPrefix>
                    <mainClass>${mainClass}</mainClass>
                </manifest>
            </archive>
        </configuration>
    </plugin>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How do I create an executable fat jar with Gradle with implementation dependencies

From Java

How do I create a jar with all dependencies using Gradle 4.4?

From Java

Intellij Maven: Create jar with all library dependencies

From Java

Maven and Netbeans: how do I build project and get executable jar?

From Java

How to put all dependencies in separate folder for runnable jar?

From Java

How can I create an executable JAR with dependencies using Maven?

From Java

How do I put all required JAR files in a library folder inside the final JAR file with Maven?

From Java

How do I compile a java file that has jar dependencies?

From Java

How can I create an executable jar without dependencies using Maven?

From Java

How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

From

How do I create a folder in a GitHub repository?

From Java

Build executable .jar with external .jar dependencies copied in a lib folder

From Dev

How do I delete all the comments in all the project from Netbeans?

From Dev

How do I locate the "lib" folder in nuget error?

From Dev

How do I create a folder in a UWP application?

From Dev

How do I only put dependencies into a specific folder for yarn?

From Dev

How to import all dependencies of a jar?

From Dev

How do i read all the Zip files present in the folder and create a new text file with all the contents

From Dev

How do I create a folder using ExtendScript?

From Dev

How do I add a jar to netbeans 7.3.1?

From Dev

How do I create an executable jar file including dependencies where the main class is in Test, using Maven

From Dev

How do I keep the /lib folder clean?

From Dev

How do I create a new folder in Mutt

From Dev

How to create a jar with Maven that includes dependencies in a separate folder for each dependency

From Dev

How do I export a JavaFX Application and dependencies in the same jar in Intellij?

From Dev

How do i open jar files created by netbeans in ubuntu?

From Dev

How can I put all dependencies into one folder inside a JAR file with Maven?

From Dev

How do I grant 'all' permissions to a netbeans project? | netbeans 8.2

From Dev

How can I create an executable/runnable JAR with dependencies using Maven?

Related Related

  1. 1

    How do I create an executable fat jar with Gradle with implementation dependencies

  2. 2

    How do I create a jar with all dependencies using Gradle 4.4?

  3. 3

    Intellij Maven: Create jar with all library dependencies

  4. 4

    Maven and Netbeans: how do I build project and get executable jar?

  5. 5

    How to put all dependencies in separate folder for runnable jar?

  6. 6

    How can I create an executable JAR with dependencies using Maven?

  7. 7

    How do I put all required JAR files in a library folder inside the final JAR file with Maven?

  8. 8

    How do I compile a java file that has jar dependencies?

  9. 9

    How can I create an executable jar without dependencies using Maven?

  10. 10

    How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

  11. 11

    How do I create a folder in a GitHub repository?

  12. 12

    Build executable .jar with external .jar dependencies copied in a lib folder

  13. 13

    How do I delete all the comments in all the project from Netbeans?

  14. 14

    How do I locate the "lib" folder in nuget error?

  15. 15

    How do I create a folder in a UWP application?

  16. 16

    How do I only put dependencies into a specific folder for yarn?

  17. 17

    How to import all dependencies of a jar?

  18. 18

    How do i read all the Zip files present in the folder and create a new text file with all the contents

  19. 19

    How do I create a folder using ExtendScript?

  20. 20

    How do I add a jar to netbeans 7.3.1?

  21. 21

    How do I create an executable jar file including dependencies where the main class is in Test, using Maven

  22. 22

    How do I keep the /lib folder clean?

  23. 23

    How do I create a new folder in Mutt

  24. 24

    How to create a jar with Maven that includes dependencies in a separate folder for each dependency

  25. 25

    How do I export a JavaFX Application and dependencies in the same jar in Intellij?

  26. 26

    How do i open jar files created by netbeans in ubuntu?

  27. 27

    How can I put all dependencies into one folder inside a JAR file with Maven?

  28. 28

    How do I grant 'all' permissions to a netbeans project? | netbeans 8.2

  29. 29

    How can I create an executable/runnable JAR with dependencies using Maven?

HotTag

Archive