Results 1 to 2 of 2
  1. #1
    nishant.4545 is offline Member
    Join Date
    Jul 2009
    Rep Power

    Default jar file problem

    hello everyone,
    the source code for my program is
    import java.util.*;
    class Sort
    public static void main(String q[])
    long start=System.currentTimeMillis();
    int a[]=new int[100000];
    Random r=new Random();
    for(int i=0;i<a.length;i++)
    for(int i=0; i<a.length-1;i++)
    for(int j=i+1;j<=a.length-1;j++)
    int t=a[j];

    long end=System.currentTimeMillis();


    then i have a created jar file of this program using following commands int the command prompt:
    echo Main-Class: Sort >manifest.txt
    jar cvfm Sort.jar manifest.txt Sort.class

    This creates the jar file. But when I try to run it by double clicking i get the error 'could not find main class. the program will exit'

    Also when i try to run it in command prompt I get an exception that it could not find the main class.

    What should I do?

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Rep Power


    the manifest file need a newline after it. Otherwise jar will strip off that line.

    also try this:
    Java Code:
    jar -efc Sort Sort.jar *.class
    //  jar -efc {Main-Class} {Jar-Name} {.class-files}
    Last edited by angryboy; 07-03-2009 at 11:00 PM.
    Get NotePad++ (free)

Similar Threads

  1. Problem while writing xml file
    By Rajesh Sahu in forum Java Servlet
    Replies: 0
    Last Post: 12-23-2008, 05:53 PM
  2. problem with jar file
    By biba84 in forum Advanced Java
    Replies: 7
    Last Post: 11-09-2008, 07:46 PM
  3. problem - using a jar file
    By jon80 in forum New To Java
    Replies: 6
    Last Post: 07-07-2008, 08:49 AM
  4. [SOLVED] file i/o problem
    By aytidaalkuhs in forum New To Java
    Replies: 3
    Last Post: 04-06-2008, 07:42 PM
  5. problem with jar file pls help
    By jinu5 in forum New To Java
    Replies: 0
    Last Post: 08-15-2007, 11:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts