Once a while is needed java executable jar file using java jar tool. Here is an example of the batch file, let’s say makejar.bat
, which can create executable jar file. Expects package name examples.
The first parameter is package subdirectory, second parameter is class with public static main method.
@echo off if "%1" == "" goto help if "%2" == "" goto help set makeSubdir=%1 set makeMainClass=%2 echo Manifest-Version: 1.0 > myManifest echo Created-By: Joe Doe >> myManifest echo Main-Class: %makeMainClass% >> myManifest rem Class-Path: lib/lib1.jar lib/lib2.jar lib/lib3.jar jar cvfm %makeSubdir%.jar myManifest examples/%makeSubdir% goto end :help echo Usage: echo %0 subdirectory Main-Class echo Example" echo %0 jlist examples.jlist.List echo . echo Creates jlist.jar echo Call: echo java -jar jlist.jar :end