Since Java 8, there is a tool that helps with packaging, named javapackager. It has many options but here we are looking only for the -createjar command:
You need to set quite a few parameters:
"$JAVA_HOME/bin/javapackager" -createjar -appclass chapterEleven.SimpleApp -outdir dist -outfile SimpleApp.jar -srcdir build/classes
Let's review them one by one:
- "$JAVA_HOME/bin/javapackager": javapackager is located in the same folder as Java; I have placed parenthesis here to avoid issues with a space in my Windows path
- -appclass chapterEleven.SimpleApp: This is the full name of the main class of our application
- -outdir dist: The name of the folder for the resulting JAR
- -outfile SimpleApp.jar: The name of ...