Could not find the main class. Program will exit.

I have a jar file that I can run fine with java from the command line in Windows. But if I try to run the same jar file from the Windows user interface by double-clicking gives me the error message that says

"Could not find the main class. Program will exit."

Has anybody ecountered the same problem or does anybody have any clues as to why I am getting this message? Any help would be very much appreciated.

I noticed that javaw is associated with the jar file and it is the program used (not java) to run all jar files.

[553 byte] By [dbh14228] at [2007-9-30 4:23:25]
# 1

Is your program in a package? If you double-click an icon to launch it, the starting directory is the icon's parent directory. If your main() method is in a class in a package, then it won't be found properly. Also, check that the signature of main() is correct (public, static, void, String[]).

- Saish

"My karma ran over your dogma." - Anon

Saish at 2007-7-1 12:53:15 > top of Java-index,Administration Tools,Sun Connection...
# 2

I too just had that roblem and it was caused by having different version of the JDK recently added to my setup changing the command line that is executed when you double click the JAR file.

So after a lot of exploring I unistalled all JDK / JRE etc, reinstalled the JDK (1.5 in my case) and it worked again.

I looked at the JAR file type command line and it NOW is :

"C:\Program Files\@Java\jre1.5.0\bin\javaw.exe" -jar "%1" %*

This is slightly different than the previous one which I did not keep a copy of. But I think the old one just said :

"C:\Program Files\@Java\jre1.5.0\bin\javaw.exe" -jar %1

Let me know if this helps fix the problem

Efran

There is no justice - Just Us

Efran at 2007-7-1 12:53:15 > top of Java-index,Administration Tools,Sun Connection...