My simplest and always working solution is copy the entire project’s dependencies to a pre-defined folder, and define the dependency classpath in the jar’s manifest file.īelow is the updated and final pom.xml, to use maven-dependency-plugin to copy all dependencies to target/dependency-jars/ folder, and use maven-jar-plugin to add the dependency classpath. The one-jar solution is really good, but I don’t like the custom class loader and fat-jar concept. – Try one-jar plugin, it will create a fat-jar, which includes the entire project’s dependencies into a single jar file, read this article – Create a fat Jar file with Maven This hack is workable in project with less dependencies only, for large project with many dependencies, it will cause Java class name conflict issue. – Alternatively, use maven-assembly-plugin to extract all dependency jars into raw classes, and group it together. – You can put both log4j.jar and jodatime.jar inside the final.jar, but your classes are unable to call other classes which is inside the unpack log4j.jar, Java jar is designed like this, unless you create a special class loader like one-jar plugin.
Update the generated App.java with the following content :Ĥ.1. The following files and folder structure will be created.Ībove folder structure is not enough, create a log4j.properties file and put it in src/main/resources/log4j.properties, just create the resources folder manually.
DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false $ mvn archetype:generate -DgroupId= -DartifactId=dateUtils
DS_Store files that us Windows folk hate cleaning up Minecraft will attempt to parse these as resources, and I can't find a posted solution atm) and you might run into an issue with assets (solution linked).In this tutorial, we will show you how to use Maven build tool, to create a single executable Jar, and how to deal with the project’s dependencies.Ĭreate a Java project from the Maven quick start template. There may be additional issues if you are on a Mac (because of the auto-generated.
zip archive will be created, including all the plugin libraries specified in the project settings. If the plugin module does not depend on any libraries, a.
• Refresh the Gradle Project in IDEA if required. In the main menu, select Build Prepare Plugin Module"Forge 1.12.1-2462" and "Forge 1.14.4-39"). The Main, or Main-Class is an essential attribute to make your jar executable.