Java jar file creation

Creating jar Files in Java

A memo on how to create jar files from the command line in Java. There are various explanations about manifest files, <code>jar cvf YourJar.jar *</code>, and <code>jar -cf</code>, which can be confusing, but in my case, I was able to do it with the following commands after compiling Java with javac -encoding UTF-8...

Shou Arisaka
1 min read
Oct 31, 2025

A memo on how to create jar files from the command line in Java.

There are various explanations about manifest files, jar cvf YourJar.jar *, and jar -cf, which can be confusing, but in my case, I was able to do it with the following commands.

# # Compile Java
javac -encoding UTF-8 -d ./build *.java
cd build
# # Can test with java SetClipboardWithBtn.
# # Set the first argument to any filename, the second argument to the class name of the main Java file, and create a jar file with all the class files to be used together.
jar cfe SetClipboardWithBtn.jar SetClipboardWithBtn *.class
# # Can execute by clicking the created jar file or with `java -jar SetClipboardWithBtn.jar`.

Reference:

jar ファイルの作成とプログラムの実行 - Java 入門

Share this article

Shou Arisaka Oct 31, 2025

🔗 Copy Links