0

I am trying to run a java executable jar from command line but it is throwing below error.

Commandline

java -jar myapp.jar com.avc.apb.printbatch.printfileuploadapplication

Error

no main manifest attribute, in myapp.jar

It is very confusing because I have manifest file inside my Jar and the file has below entry .

Main-Class: com.avc.apb.printbatch.printfileuploadapplication

My Jar structure is below.

myapp.jar
      -com
      -META-INF
            -MANIFEST.MF
      -application.properties
      -otherfiles

Manifest.mf contents

Manifest-Version: 1.0
Build-Jdk_Spec: 1.8
Created-By: Maven Jar Plugin 3.2.0
Main-Class: com.avc.apb.printbatch.printfileuploadapplication
Saimuga
  • 255
  • 1
  • 5
  • 16
  • It probably won't fix anything, but what if you try just `java -jar myapp.jar`? You don't need to pass the main class when launching a jar file. Though what you currently have should just pass that as an application argument. – Slaw Nov 07 '21 at 05:46
  • `Mainfest-Version` is misspelt – tgdavies Nov 07 '21 at 05:52
  • Slaw: I tried but still getting same error. @tgdavies Sorry, thats just typo. Corrected it in this post. Please suggest if there are any other ideas. Thanks !!! – Saimuga Nov 07 '21 at 13:03
  • 2
    Make sure there is **an empty line at the end** of the manifest file, especially if you have editted or modified it. Though invisible and lost when you cut&paste (e.g. to a website), this is [part of the required format](https://docs.oracle.com/javase/8/docs/technotes/guides/jar/jar.html#Manifest_Specification) – dave_thompson_085 Nov 07 '21 at 16:52
  • @dave_thompson_085 I never knew this and never would have guessed it !!!! It worked like a charm... Thanks very much.. Please post this as answer . – Saimuga Nov 07 '21 at 17:16

0 Answers0