differences between "javaw" and "java -jar"
I am making an installer. The installer is packaged in a jar. It creates a jar file that contains the content to be installed and appropriate extractor classes. When I execute the jar using the command line, I can use two different commands:
"javaw myJar.jar"
OR
"java -jar myJar.jar"
When I use javaw, I get a message box saying no main class is found. When I use java -jar, the installer runs normally. When I d-click the installer jar, and try to make a jar a dos window opens up with the header "c:\jdk1.3.1\bin\jar.exe" and does nothing from that point on. It will close normally though.
Thanks!!
Jason R. Kretzer
[668 byte] By [
JMagnus] at [2007-9-26 1:23:29]

javaw and java are both used to interpret java programs, javaw is used for those with a visual interface.
The -jar parameter instructs either of the interpreters to get its classes from the specified jar file.
Presumably you have a UI for your installer, so you should use the command javaw -jar myJar.jar
HTH,
Neil.
>
> When I use javaw, I get a message box saying no main
> class is found.
In the jar file, there is something called the manifest as you should know. In the manifest, you need to add a line that look like this:
main-Class: mainclass
you just put the name of the main class you want to start, without any extension (not mainwindow.class but mainwindow) The class must be found in the jar file of course (but I don't think I really need to tell you )
I found the same thing with javaw and java, that you have to add -jar and create a manifest in the jar with a proper Main-Class entry. No doubt, this is as things are meant to be.
However, I can't double click on the jar and get it to run my application. Win98 asks me how to open the file, so I tell it to use java (I've also tried javaw). This fails (presumably because java (or javaw) is invoked with no -jar flag). Am I missing something, or is this normal. If so, should I create my own batch file, e.g. javajar.bat that looks like
@java -jar %1