Problem with "javaw" comand
I have tried running a jar file various ways. Now I wanted to try of course by double clicking the file. And I know I should associate the jar file with the javaw.exe. And I have done so. However I keep getting the message: "Could not find the main class. Program will exit." The manifest is ok, as everything works perfectly when I execute the jar file from netBeans or from the command line using java -jar ... and also with a batch file. But I can not get it execute by double click.
Anyone have a suggestion on how to solve this problem?
Thank you!
[571 byte] By [
Tyraela] at [2007-11-27 6:38:19]

If your claim that everything worked ok from the command line is
correct than the problem is with the manifest file.
there is some stupid rule about pressing enter (line break) at
the end of a manifest file. check on that first.
also post back with how you configured the javaw jar file association.
mine is:
"C:\Program Files\Java\jre1.6.0\bin\javaw.exe" -jar "%1" %*
with program = javaw
If when you run it from the command prompt as it as >java -jar MyJarFile.jar and it works fine, then I assume you are seeing the class not found Exception from the java console? If so, it actually sound like it might be a classpath problem. Did you drag and drop the jar onto your desktop and double click on it from there, or from the same directory where you run it from using the command prompt?
Thanks for your reply!
I know that stupid rule with the manifest file! I checked it a couple of times. It's not it.
It might be the file asociation. Well, I just specified that the jar files should be opened with the javaw program in the Tools>Folder Options>File types menu ( windows xp ). I don't know how to do the association as you have it. Can you please explain me...
Thanks!
for Windows:C:\>assoc .jarassoc /?C:\>ftype jarfileftype /?
Thanks for your reply, abillconsl!I am not seeing any exceptions anyware when I execute it from the console or in netbeans. And I did try it through various locations, including desktop and still doesn't work! ( locations are the same as where i run the command prompt )
> I don't know how to do the> association as you have it. Can you please explain me... Tools>Folder Options>File types JAR > ADVANCED > open + edit
> Thanks for your reply, abillconsl!
>
> I am not seeing any exceptions anyware when I execute
> it from the console or in netbeans. And I did try it
> through various locations, including desktop and
> still doesn't work! ( locations are the same as where
> i run the command prompt )
In case TuringPest's reply does not satisfy your pblm, what I meant was - "How are you seeing a Class Not Found Excpetion if you are double clicking it? ... no doubt you opened the Java Console and viewed it there?". If not, please specify.
I have looked on the association in the command line as well it's the right one. The same as you mentioned ( TuringPest ) . The association is ok.
It's just a error window ( like a JOptionPane error message ). No console because javaw executes without opening the console. The Winow just states "Could not find the main class. Program will exit." and I have a common error icon. That's all.
try a new one with java,exe:assoc .jar=myjarfileftype myjarfile="C:\Program Files\Java\jre1.6.0\bin\java.exe" -jar "%1" %*
> I don't know how to do the
> association as you have it. Can you please explain me...
Tools>Folder Options>File types
JAR > ADVANCED > open + edit
Tried it... as I mentioned before I think the association is ok! I have exactly in the same format as yours.
> try a new one with java,exe:assoc> .jar=myjarfile> ftype myjarfile="C:\Program> Files\Java\jre1.6.0\bin\java.exe" -jar "%1" %*tried it! still the same problem!
exactly the same? with java.exe (not javaw.exe)
and using a new assoc "myjarfile"? (seems like we have to trick out windows)
sorry, but it should work, so the need to make some "strange" tests
what about using the full path to run from command line:C:\>C:\Program Files\Java\jre1.6.0\bin\java.exe -jar ...
I think the time has come for you to show us your:>File/package structure;>manifest file name and contents;>javac/build command;>jar build;>java command line run string.
> I think the time has come for you to show us your:
>
> >File/package structure;
> >manifest file name and contents;
> >javac/build command;
> >jar build;
> >java command line run string.
Ok. Here is my code:
package Test;
import javax.swing.JOptionPane;
public class Test {
public static void main( String args[] )
{
JOptionPane.showMessageDialog( null, "Is working! " );
}
}
Here is what I have in the manifest file:
Manifest-Version: 1.0
Main-Class: Test.Test
I repeat: running the jar file from netbeans by rightclicking it works perfectly.
The same is when I run:
c:\>javaw -jar "c:\Test\Test.jar" ( the jar file is also named Test )
... it works with no problems, no exceptions etc.
The jar is created in netbeans 3.6 .
It compiles with no problems.
I also mention that I use java 1.5.0 but I don't think that makes any difference.
I don't see why that would be from the info you have furnished.
Try this, from the command prompt:
>cd \
... now from the 'c' root directory ...
>javac Test\*.java
>jar cvmf0 Test\whtever_my_manifest_file_is_called_manifest Test\Test.jar Test\*.class
>java -jar Test\Test.jar
Now, if it runs like that, next try double clicking it.
> I don't see why that would be from the info you have
> furnished.
>
> Try this, from the command prompt:
>
> >cd \
>
> ... now from the 'c' root directory ...
>
> javac Test\*.java
> >jar cvmf0
> Test\whtever_my_manifest_file_is_called_manifest
> Test\Test.jar Test\*.class
> >java -jar Test\Test.jar
>
> ow, if it runs like that, next try double clicking it.
I have tried that previously and still doesn't work. I have even installed jdk 1.6.0 and I get the same thing. Anyway, it may be the OS or something external cause I cannot find something else to blame!
You did everything exactly as I wrote it - no deviation except for your names?