jar
command: e
. Other options of the jar
command are still the same. This is the partial usage from JDK 6 beta 2:C:\tools\jdk6\bin > jarFor example, I run
Usage: jar {ctxui}[vfm0Me] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options:
...
-e specify application entry point for stand-alone application
bundled into an executable jar file
...
jar
command to package a self-contained application in a jar file:C:\ws\nb\scrap\build\classes > C:\tools\jdk6\bin\jar cvfe ..\..\dist\hello-world.jar com.javahowto.test.HelloWorld comThen I can distribute hello-world.jar to users, who can run hello-world app like this:
added manifest
adding: com/(in = 0) (out= 0)(stored 0%)
adding: com/javahowto/(in = 0) (out= 0)(stored 0%)
adding: com/javahowto/test/(in = 0) (out= 0)(stored 0%)
adding: com/javahowto/test/HelloWorld.class(in = 572) (out= 348)(deflated 39%)
C:\download\hello > java -jar hello-world.jarUsers can run it with any version of java; it doesn't have to be JDK 6. What the extra
Hello world!
e
option does is simply adding a Main-Class
entry in the jar's META-INF\MANIFEST.MF
:Manifest-Version: 1.0This new feature is helpful when packaging simple self-contained apps, and application client modules in J2EE/JavaEE, both of them require a
Created-By: 1.6.0-beta2 (Sun Microsystems Inc.)
Main-Class: com.javahowto.test.HelloWorld
Main-Class
entry in MANIFEST.MF. So I don't have to create one beforehand, or have Apache Ant generate one.Tags: