Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3220046
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:42:59+00:00 2026-05-17T15:42:59+00:00

I create jar file with command. $jar -cvf A.jar A.class I tried executing $java

  • 0

I create jar file with command.

$jar -cvf A.jar A.class

I tried executing

$java -jar A.jar 

I am getting below error.(Before adding “Main-class : A” to manifest.mf)

Failed to load Main-Class manifest attribute from A.jar

contents of MANIFEST.MF

Manifest-Version: 1.0

Created-By: 1.6.0_18 (Sun Microsystems Inc.)
Main-Class: A

Now i am getting

Exception in thread "main" java.lang.NoSuchMethodError: main
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:42:59+00:00Added an answer on May 17, 2026 at 3:42 pm

    Usually you don’t need to specify an Manifest file when you create a jar, but as you want to start your jar by launching java -jar you must specify your own manifest which details where is the class containing the main() method.

    In order to do this you have to create a file containing this line :

    Main-Class: A
    

    (I suppose A is your class containing your main method, if it isn’t the case specify the FQN of your desired class)

    and create your jar with the following command :

    jar cfm A.jar yourFileContainingMain-Class A.class
    

    For example :

    //Mac-Makkhdyn:~ Makkhdyn$ cat A.java
    public class A{
    public static void main(String... args){
    System.out.println("lol");
    }
    }
    //Mac-Makkhdyn:~ Makkhdyn$ cat manifest 
    Main-Class: A
    //Mac-Makkhdyn:~ Makkhdyn$ javac A.java
    //Mac-Makkhdyn:~ Makkhdyn$ jar cvfm A.jar manifest A.class 
    added manifest
    adding: A.class(in = 399) (out= 278)(deflated 30%)
    //Mac-Makkhdyn:~ Makkhdyn$ java -jar A.jar
    lol
    

    After your edit :

    You must have a main() method in your A class you want to launch. Check the link below.


    Resources :

    • oracle.com – Setting an Application’s Entry Point
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to create jar file using command line that I inserted into java
I want to create registry key through java program to add the jar file
What is the Java equivalent to this jar command: C:\>jar cvf myjar.jar directory I'd
How can I create the class file and jar file for this coding, when
How does one create a JAR file programmatically using java.util.jar.JarOutputStream ? The JAR file
I have jar files which I constructed using command jar -cf Generic.jar /java/mypackage/*.class There
I am trying to create a jar file off of a class and xml
I'm running jar in order to create a JAR file with the command: jar
i want to create a jar file of my java web application. This web
Hello all how can I create jar file of my project that is created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.