Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corrupt jar file

I have created a jar file in windows 7 using eclipse. When I am trying to open the jar file it says invalid or corrupt jar file. Can anyone suggest me why the jar file is invalid?

like image 622
Neel Avatar asked Sep 26 '11 17:09

Neel


People also ask

Can a JAR file be a virus?

The JAR malware detection range is from 0 to 99.10%, depending on the antivirus software. On average, 34.95% of virtual viruses were detected.

Can jar files harm your computer?

Yes and No. By default java programs can do the same things any native program on your system can do. This includes deleting and replacing any file it can access, depending on your operating system and your user privileges this may affect system critical files.


1 Answers

This will happen when you doubleclick a JAR file in Windows explorer, but the JAR is by itself actually not an executable JAR. A real executable JAR should have at least a class with a main() method and have it referenced in MANIFEST.MF.

In Eclispe, you need to export the project as Runnable JAR file instead of as JAR file to get a real executable JAR.

Or, if your JAR is solely a container of a bunch of closely related classes (a library), then you shouldn't doubleclick it, but open it using some ZIP tool. Windows explorer namely by default associates JAR files with java.exe, which won't work for those kind of libary JARs.

like image 65
BalusC Avatar answered Oct 07 '22 22:10

BalusC