aspose file tools*
The moose likes Java in General and the fly likes Problem with JAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem with JAR file" Watch "Problem with JAR file" New topic
Author

Problem with JAR file

Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Ive created a Jar File thar does perfom some file comparision stuff.
When i run the Jar file via command prompt,
java -jar FileCompare.jar

it works fine but when i double click the jar file it does'nt work, it throws an error
"Could not find the main class. Program will exit."

What could be the reason.


SCJP 1.5
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38840
    
  23
Have you put a Main attribute in your manifest file? Have you got a newline at the end of your manifest file?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38840
    
  23
Have you got a file association in your OS to associate jar files with the appropriate java runtime?
Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99

Yes, Ive put the Main Attribute in the manifest file. Its working fine with command prompt, but fails to run when i double click it.


Sorry i dint get you!!
Bharadwaj Adepu
Ranch Hand

Joined: Dec 30, 2007
Posts: 99
Any one please help me!!
Prakash Subramanian
Ranch Hand

Joined: Feb 03, 2005
Posts: 32
Do you see your JAR file being displayed with a standard java coffee icon in your windows explorer view? It should list as an executable jar file. If so, then your OS file association is right. Else you can just click on 'open with' and then associate your java.exe with it. Make sure your manifest file is right, as mentioned in the previous post. It is easy to miss out.

I guess this should be moved to the beginner's forum.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19693
    
  20

Bharadwaj,

please read the following link: PatienceIsAVirtue


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with JAR file