United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4291383 Add a -mainClass parameter to the JAR tool (for easy autorunnable JARs creation)
JDK-4291383 : Add a -mainClass parameter to the JAR tool (for easy autorunnable JARs creation)

Details
Type:
Enhancement
Submit Date:
1999-11-15
Status:
Resolved
Updated Date:
2005-09-17
Project Name:
JDK
Resolved Date:
2005-09-17
Component:
tools
OS:
windows_nt,generic
Sub-Component:
jar
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.0,1.3.0,1.4.0
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
Name: mc57594			Date: 11/15/99


java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)



I'd suggest you add a -mainClass parameter to the JAR tool, so that doing for
example

JAR -mainClass xxx.yyy.ZZZClassName output\xxx\yyy\*.class images\*.gif

would make a jar which when double clicked would run the class
<xxx.yyy.ZZZClassName>

then the JAR tool would add the "Main-Class:" header to the manifest.mf
automatically if -mainClass command line parameter was passed to it
(Review ID: 97815) 
======================================================================

                                    

Comments
WORK AROUND



Name: mc57594			Date: 11/15/99


Now user has to write his own manifest file with the Main-Class header in it
and when building the .jar file tell JAR.EXE to merge this one with the jar's
manifest file which the JAR tool will generate (we can't just replace the JARs
manifest in case some other entries are in it - in Java2 it's usually OK cause
for non-signed JARs the JAR tool makes an empty manifest with a default
format/version header)
======================================================================

I have scripts containing code like:

MkManifestWithClassPath() {
    (echo "Manifest-Version: 1.0"; echo "Main-Class: Main"; echo "Class-Path: $*") > MANIFEST.MF
}

###@###.### 2005-05-19 19:34:26 GMT
                                     
2005-05-19
EVALUATION

This proposal is a small increase in convenience for the
creator of a jar file, at the cost of a small increase in 
complexity of the jar documentation and implementation.

This proposal is effectively a special purpose "editing"
function that is so specialized it probably doesn't belong
in the jar tool.  Usually the Main-Class attribute will
be written at the same time the jar file is created.

One can imagine many other special "editing" options, like
-Class-Path to update the class path attribute, that would
be hard to understand and not provide too much functionality.

I recommend closing this rfe as "will not fix".
###@###.### 2005-05-19 19:34:26 GMT
                                     
2005-05-19
EVALUATION

A new flag 'e' has been added to the jar command's initial set of flags to specif
the application entry point.

jar {ctxu}[vfm0Mie] [jar-file] [manifest-file] [entry-point] [-C dir] files
                 ^                              ^^^^^^^^^^^
                                     
2005-09-12



Hardware and Software, Engineered to Work Together