JDK-4291383 : Add a -mainClass parameter to the JAR tool (for easy autorunnable JARs creation)
  • Type: Enhancement
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 1.2.0,1.3.0,1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1999-11-15
  • Updated: 2017-05-16
  • Resolved: 2005-09-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6 b53Fixed
Related Reports
Duplicate :  
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
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

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

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