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

    Default could not find main class, the program wil exit-- error in jar file

    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++)
    a[i]=r.nextInt();
    for(int i=0; i<a.length-1;i++)
    {
    for(int j=i+1;j<=a.length-1;j++)
    {
    if(a[i]>a[j])
    {
    int t=a[j];
    a[j]=a[i];
    a[i]=t;}
    }}

    long end=System.currentTimeMillis();
    System.out.println("time:"+(end-start));

    }}

    Then i have created a jar file of this program using following commands in 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
    Posts
    742
    Rep Power
    6

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2011, 09:48 PM
  2. Replies: 6
    Last Post: 05-18-2010, 05:11 PM
  3. [SOLVED] Could not find the main class: error...
    By bobleny in forum New To Java
    Replies: 21
    Last Post: 03-02-2010, 10:53 AM
  4. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 10:02 AM
  5. Could not find the main class. Program will exit.
    By Carrier in forum New To Java
    Replies: 1
    Last Post: 04-22-2009, 02:27 AM

Posting Permissions

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