From the course: Gradle for Java-Based Applications and Libraries

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Packaging a JAR file

Packaging a JAR file

From the course: Gradle for Java-Based Applications and Libraries

Start my 1-month free trial

Packaging a JAR file

- [Instructor] Java programs are usually not executed by pointing the Java executable to just a set of classes and resource files. It's best practice to create an archive that contains all necessary files to operate the application. The most common archive is the JAR, the Java archive file. In this video, you will learn how to create a JAR file for a Java application. The JAR task provided by the Java plugin understands how to bundle classes and resource files into the JAR file. It knows where to find the necessary files we compiled earlier and triggers compilation as a task dependency if the user didn't execute compilation yet. There's nothing special you have to configure in the build script to execute the JAR task. So let's try it out. Run the command gradlew jar and watch Gradle do its job. After the build finished, you will find the produced archive file in the directory build libs. That's one of these standard…

Contents