Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 08:23 PM
Member
 
Join Date: Jul 2009
Posts: 10
Rep Power: 0
nishant.4545 is on a distinguished road
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++)
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 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?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-03-2009, 09:36 PM
angryboy's Avatar
Senior Member
 
Join Date: Jan 2009
Location: Javaland
Posts: 743
Rep Power: 2
angryboy is on a distinguished road
Default
the manifest file need a newline after it. Otherwise jar will strip off that line.

also try this:
Code:
jar -efc Sort Sort.jar *.class

//  jar -efc {Main-Class} {Jar-Name} {.class-files}
__________________
USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)

Last edited by angryboy; 07-03-2009 at 11:00 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +2. The time now is 04:59 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org