File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Executable jars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Executable jars" Watch "Executable jars" New topic
Author

Executable jars

Tom Triolo
Greenhorn

Joined: Oct 06, 2002
Posts: 15
I created an application on a Windows Me machine, jar'ed the files and included a manifest.mf with the Main-Class: appWithMain (and a newline).
Windows Me doesn't recognize it as an executable but if I use the same jar file on a Win 98 machine, it starts. The Win Me machine pops up the old familiar, "Open With..." dialog.
What am I not doing right here?
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Tom,
Do you have the JRE installed on the ME machine? If so then when it pops up the open with then select javaw and that should do the trick.
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Tom Triolo
Greenhorn

Joined: Oct 06, 2002
Posts: 15
The jre is installed, this is the machine that I wrote and tested it on. I tried using javaw and it says it can't find the main class. My main class is listed in the third line of the mainifest.mf file which is in the meta-inf directory.
Manifest-Version: 1.0
Created-By: 1.4.0_01 (Sun Microsystems Inc.)
Main-Class: classWithMain
Directory structure is
two packages:
1) org.jakarta.apache.otherDirs
2) MyDir.myFiles
and the file with the classWithMain is not in a directory, but I guess you could say it is at the root of the jar file.

If I use java -jar jarFile, it starts but then it does throw an exception later when I try and do something else. Perhaps I have not included a file, or my structure is wrong.
Whhaadddyyaaa think?
Tom
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Tom,
You said in your first post the main was appWithMain but in your manifest you say classWithMain. Could that be the problem? Also what package is your main class in? If not in the default package that should be reflected int the manifest. You also need to be sure that you can't see any of the classes outside the jar (which may be in the jar) thru the CLASSPATH.
Hope this helps,
Michael Morris
Tom Triolo
Greenhorn

Joined: Oct 06, 2002
Posts: 15
It is the class that contains main. It instantiates an object which is in the package that it imports. The classes in this package which is imported, themselves import classes from another package which is also in the jar file. The main class is not in any special package. I guess that may be the default package it is in then. And the manifest.mf file is in a meta-inf directory. I do not set any classpaths. It will start on a Win 98, as it is recognized as an executable. The Win Me does not recognize is as such.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Executable jars