3

I am trying to run jar file through

java -jar jts.jar

but it is unable to run because it's Manifest.mf do not contain 'Main-Class' attribute, which is necessary for a jar file to run.

I am have same problem with 9-10 .jar files. Help me with how to find those mainclass in jar files, there is no any directly defined mainclass in jar file. How should I find the correct mainclass and how should I add it to manifest.mf

user2496080
  • 31
  • 1
  • 2

3 Answers3

0

On command line you can use following command to generate jar having existing manifest.

jar cvfm MyJarName.jar manifest.txt *.class

Refer this page for more details.

Alternatively, if you are using eclipse. Please follow steps mentioned here to export jar.

Dark Knight
  • 8,218
  • 4
  • 39
  • 58
0

if you have your Main-Class attribute on the last line of your manifest.txt, it vanishes if you do not have a new line at the end. Very annoying, but always make sure you have a new line at the end of your manifest file.

ooocp
  • 1
-1
1. You can open the jar file with winzip or winrar. 
2. Open manifest file in notepad. 
3. Add main-class: ClassNameContianingMainMethod. 
4. Save the file and then run it 
Bhushan
  • 354
  • 9
  • 25