Exporting an Applet to a Jar File [message #116862] |
Fri, 14 November 2003 03:05  |
Eclipse User |
|
|
|
Hi,
Does anyone know if there is a way to get the JAR Export tool to allow
for an applet to be specified as the main class as opposed to a class with
a main() method?
The third screen in the JAR export process is the 'JAR Manifest
Specification' page, and the last line is 'Main Class - select the class
of the application entry point:'. Unfortunately I am unable to select my
Applet class (sub-class of JApplet with init() method) in this field. I
get the error message 'The selected main class is not selected for export
or has no main method' when I try to type in the class name manually.
I even tried editing the generated .jardesc file to change the
mainclass, but still no luck.
For now I'm using the work-around of using a DOS batch file which is
working fine, but it seems silly not to be able to do this directly
through eclipse.
Thanks,
Jon Harris.
|
|
|
|
Exporting an Applet to a Jar File (feature request) [message #117132 is a reply to message #116876] |
Fri, 14 November 2003 18:13   |
Eclipse User |
|
|
|
Daniel Megert wrote:
> Jon Harris wrote:
> >Hi,
> >
> > Does anyone know if there is a way to get the JAR Export tool to allow
> >for an applet to be specified as the main class as opposed to a class with
> >a main() method?
> >
> >
> No, since the Main-Class attribute is defined for stand-alone
> applications (see the Jar File specification for more details).
Which 'Jar File specification' are you referring to?
If you are referring to Sun's jar file tool, then this quote from Sun's
documentation title 'Running JAR-Packaged Software' suggests that applets
are supposed to be supported by jar files:
------------------------------------------------------------ ----------------
To indicate which class is the application's entry point, you must add a
Main-Class header to the JAR file's manifest. The header takes the form:
Main-Class: classname
The header's value, classname, is the name of the class that's the
application's entry point.
------------------------------------------------------------ ----------------
Note that nothing specific is said that restricts Main-Class values to be
classes with a main() method.
Also, Sun's website uses applets in jar files are over the place, implying
that applets are intended to be packagable into jar files,
Creating an applet jar file from the command line using Sun's standard
j2sdk jar tool is simple.
For example, I can do the following assuming I've written and compiled
MyApplet.java which is a subclass of JApplet:
Create an ascii text file called manifest.mf
Type 'Main-Class: MyJApplet' in the first line of manifest.mf (without
quotes)
Run the following command:
jar cmf manifest.mf MyJApplet.jar MyJApplet.class
I can then include MyJApplet.jar in the applet tag of an html document,
and when the page is loaded, the init method of the MyJApplet class gets
called (provided the java plug-in is installed).
I guess what I'm saying is that creating applet jar files is something I
do fairly often, and it'd be nice to have this feature in eclipse... I'm
new to eclipse, but proficient in java... Can anyone tell me where the
source code for the jar export tool is in eclipse? I could probably modify
it myself. :-)
Jon.
> Dani
> > The third screen in the JAR export process is the 'JAR Manifest
> >Specification' page, and the last line is 'Main Class - select the class
> >of the application entry point:'. Unfortunately I am unable to select my
> >Applet class (sub-class of JApplet with init() method) in this field. I
> >get the error message 'The selected main class is not selected for export
> >or has no main method' when I try to type in the class name manually.
> >
> > I even tried editing the generated .jardesc file to change the
> >mainclass, but still no luck.
> >
> > For now I'm using the work-around of using a DOS batch file which is
> >working fine, but it seems silly not to be able to do this directly
> >through eclipse.
> >
> >Thanks,
> > Jon Harris.
> >
> >
> >
|
|
|
Re: Exporting an Applet to a Jar File (feature request) [message #117243 is a reply to message #117132] |
Sat, 15 November 2003 14:05   |
Eclipse User |
|
|
|
Originally posted by: daniel.megert.gmx.net
Jon Harris wrote:
>Daniel Megert wrote:
>
>
>
>>Jon Harris wrote:
>>
>>
>
>
>
>>>Hi,
>>>
>>> Does anyone know if there is a way to get the JAR Export tool to allow
>>>for an applet to be specified as the main class as opposed to a class with
>>>a main() method?
>>>
>>>
>>>
>>>
>>No, since the Main-Class attribute is defined for stand-alone
>>applications (see the Jar File specification for more details).
>>
>>
>
>Which 'Jar File specification' are you referring to?
>
>If you are referring to Sun's jar file tool, then this quote from Sun's
>documentation title 'Running JAR-Packaged Software' suggests that applets
>are supposed to be supported by jar files:
> ------------------------------------------------------------ ----------------
>To indicate which class is the application's entry point, you must add a
>Main-Class header to the JAR file's manifest. The header takes the form:
>
>Main-Class: classname
>
>The header's value, classname, is the name of the class that's the
>application's entry point.
> ------------------------------------------------------------ ----------------
>
>Note that nothing specific is said that restricts Main-Class values to be
>classes with a main() method.
>
>
Yes it is: it says application which means there's a main() method. You
do not need to specify the Main-Class attribute for an applet. Here's
what the spec says how Main-Class is used:
* attribute defined for stand-alone applications
This attribute is used by stand-alone applications that are
bundled into executable jar files which can be invoked by the java
runtime directly by running "java -jar x.jar".
o Main-Class :
The value of this attribute defines the relative path of the
main application class which the launcher will load at
startup time. The value must /not/ have the .class extension
appended to the class name.
If you still think you need/want that attribute you can include your own
manifest file when building the JAR.
Dani
>Also, Sun's website uses applets in jar files are over the place, implying
>that applets are intended to be packagable into jar files,
>
>Creating an applet jar file from the command line using Sun's standard
>j2sdk jar tool is simple.
>
>For example, I can do the following assuming I've written and compiled
>MyApplet.java which is a subclass of JApplet:
>
>Create an ascii text file called manifest.mf
>Type 'Main-Class: MyJApplet' in the first line of manifest.mf (without
>quotes)
>Run the following command:
> jar cmf manifest.mf MyJApplet.jar MyJApplet.class
>
>I can then include MyJApplet.jar in the applet tag of an html document,
>and when the page is loaded, the init method of the MyJApplet class gets
>called (provided the java plug-in is installed).
>
>I guess what I'm saying is that creating applet jar files is something I
>do fairly often, and it'd be nice to have this feature in eclipse... I'm
>new to eclipse, but proficient in java... Can anyone tell me where the
>source code for the jar export tool is in eclipse? I could probably modify
>it myself. :-)
>
>Jon.
>
>
>
>>Dani
>>
>>
>
>
>
>>> The third screen in the JAR export process is the 'JAR Manifest
>>>Specification' page, and the last line is 'Main Class - select the class
>>>of the application entry point:'. Unfortunately I am unable to select my
>>>Applet class (sub-class of JApplet with init() method) in this field. I
>>>get the error message 'The selected main class is not selected for export
>>>or has no main method' when I try to type in the class name manually.
>>>
>>> I even tried editing the generated .jardesc file to change the
>>>mainclass, but still no luck.
>>>
>>> For now I'm using the work-around of using a DOS batch file which is
>>>working fine, but it seems silly not to be able to do this directly
>>>through eclipse.
>>>
>>>Thanks,
>>> Jon Harris.
>>>
>>>
>>>
>>>
>>>
>
>
>
>
|
|
|
Re: Exporting an Applet to a Jar File (feature request) [message #117320 is a reply to message #117243] |
Sat, 15 November 2003 16:52  |
Eclipse User |
|
|
|
I just realized something important... The manifest.mf file in my applet
jar file is not even being used... I didn't realize that this whole time
the code tag in the html was telling the java plug-in which class to
load...
My mistake, sorry for wasting your time... :-)
Thanks,
Jon.
Daniel Megert wrote:
> Yes it is: it says application which means there's a main() method. You
> do not need to specify the Main-Class attribute for an applet. Here's
> what the spec says how Main-Class is used:
> * attribute defined for stand-alone applications
> This attribute is used by stand-alone applications that are
> bundled into executable jar files which can be invoked by the java
> runtime directly by running "java -jar x.jar".
> o Main-Class :
> The value of this attribute defines the relative path of the
> main application class which the launcher will load at
> startup time. The value must /not/ have the .class extension
> appended to the class name.
> If you still think you need/want that attribute you can include your own
> manifest file when building the JAR.
> Dani
|
|
|
Powered by
FUDForum. Page generated in 0.04385 seconds