This is quite frustrating! In the documents, and in the newsgroups, I see
simple instructions like the following:
===============================================
==========Beginning of Ray's example=================
===============================================
Suppose you want to run class com.xyz.Main. Then create a manifest file
like this:
======== main.mf starts on the next line ====
Main-Class: com.xyz.Main
======== end of main.mf =====================
(Where the lines with === above are not actually in the file.)
Then create your jar file:
$ jar cvfm xyz.jar main.mf com/xyz/*.class
===============================================
=========end of Ray's example=======================
===============================================
With such simple instructions, it is quite frustrating to see the
recommended procedure failing without any information as to what caused the
problem.
I have appended what I see in the command console after following Ray's
instructions, changing only file and class names to match the files I'm
using in my test. No error ever appears in the comsole or when compiling
the code. However, when I try to run it, I get an error message dialog box
saying that the main class could not be found.
I do not know if it makes a difference, but HotSpotImageTest is derived from
JApplet and has function main. It runs fine within JBuilder, and I have
compiled it without problems from the command line using only Sun's SDK.
And it runs fine as an applet, but this jar file business is giving me
grief.
If it makes a difference, this application/applet makes considerable use of
Swing.
Once this problem is resolved, I need to be able to make the jar file self
contained, including in it everything that the application needs to run so
that I do not have to worry about the version of the java runtime on the
client machine or whether or not there is support for Swing on it. IS this
possible? If so, how? I do not really want to be installing a new JVM on a
client machine unless I absolutely have no choice in the matter.
Thanks,
Ted
=======contents of manifest.mf==(including a couple empty lines at the end
of the file)====
Main-Class: HotSpotImageTest
===========Partial session record==================
H:\JavaProjects\HotImage\HotImage\classes\hotimage >dir
Volume in drive H is Local Disk
Volume Serial Number is 686B-F4CF
Directory of H:\JavaProjects\HotImage\HotImage\classes\hotimage
06/04/2004 01:06p <DIR> .
06/04/2004 01:06p <DIR> ..
28/03/2002 11:29p 78,727 daynite.gif
28/03/2002 11:18p 7,667 deerani.gif
31/03/2004 04:07p 4,757 HotSpotImageTest.class
06/04/2004 01:06p 103,281 HotSpotImageTest.jar
31/03/2004 04:07p 683
HotSpotImageTest_jLabel1_mouseAdapter.class
31/03/2004 04:07p 935
HotSpotImageTest_jLabel2_mouseAdapter.class
06/04/2004 01:04p 30 manifest.mf
21/06/2003 04:42a 100,096 sunset.jpg
8 File(s) 296,176 bytes
2 Dir(s) 17,338,773,504 bytes free
H:\JavaProjects\HotImage\HotImage\classes\hotimage >HotSpotImageTest
'HotSpotImageTest' is not recognized as an internal or external command,
operable program or batch file.
H:\JavaProjects\HotImage\HotImage\classes\hotimage >HotSpotImageTest.jar
H:\JavaProjects\HotImage\HotImage\classes\hotimage >jar cvfm
HotSpotImageTest.jar manifest.
mf *.class *.jpg
added manifest
adding: HotSpotImageTest.class(in = 4757) (out= 2304)(deflated 51%)
adding: HotSpotImageTest_jLabel1_mouseAdapter.class(in = 683) (out=
358)(deflated 47%)
adding: HotSpotImageTest_jLabel2_mouseAdapter.class(in = 935) (out=
413)(deflated 55%)
adding: sunset.jpg(in = 100096) (out= 99228)(deflated 0%)
H:\JavaProjects\HotImage\HotImage\classes\hotimage >HotSpotImageTest.jar
H:\JavaProjects\HotImage\HotImage\classes\hotimage >