0

Any idea why

java -jar jarname.jar

works, but double clicking the jar gives a

"Could not find the main class:"

error? Manifest is correctly placed and double clicking was working until recently, but all of a sudden it gives that error. I'm not sure what changes I made though.

EDIT:
The command I used to create the jar was (in cmd):

jar cfe jarname.jar files.Main *

Main is part of the package files.

user1102901
  • 565
  • 1
  • 4
  • 12
  • See http://stackoverflow.com/questions/10875839/jar-file-keeps-giving-me-could-not-find-the-main-class-program-will-exit and http://stackoverflow.com/questions/8629412/generated-runnable-jar-could-not-find-the-main-class – Suresh Kumar Jun 13 '12 at 04:15

3 Answers3

1

Add this entry in your manifest file:

Main-Class: com.abc.def.YourMainClass

Hope this'll help!

HashimR
  • 3,803
  • 8
  • 32
  • 49
0

Some time ago I had a comparable problem. And it was caused by multiple JDK/JRE versions on my machine. What is used by double-clicking differs from what is used by typing jar in a shell.

I think JarFix could help. Or you lookup what is associated with double-click in the file-associations (reinstall java might also help)

matcauthon
  • 2,261
  • 1
  • 24
  • 41
0

It seems to have been some weird compiler version problem. When I complied the class files using an older version of java, then compiled it into a .jar file, it was able to run.

user1102901
  • 565
  • 1
  • 4
  • 12