• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot find main class.program will exit. error in jar file creation

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i created a jar file in eclipse.

my manifest file is:

Manifest-Version: 1.0
Main-Class: EmailClient
Class-Path: mail.jar

when i click the jar file i am getting

cannot find main class.program will exit.

please help..


 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

gayathri murugesan wrote:
cannot find main class.program will exit.



Obvious question. Does the jar file contain the main class (ie. EmailClient.class)? Can you do a "jar tvf" to show us what's in the jar?

Henry
 
gayathri murugesan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

D:\pro>jar tvf test2.jar
0 Sat Mar 13 16:39:48 IST 2010 META-INF/
97 Sat Mar 13 16:39:48 IST 2010 META-INF/MANIFEST.MF
7044 Sat Mar 13 08:58:44 IST 2010 BasicJDBCDemo.class
8470 Sat Mar 13 08:58:44 IST 2010 Classifier.class
516 Sat Mar 13 08:58:44 IST 2010 ConnectDialog$1.class
543 Sat Mar 13 08:58:44 IST 2010 ConnectDialog$2.class
543 Sat Mar 13 08:58:44 IST 2010 ConnectDialog$3.class
4350 Sat Mar 13 08:58:44 IST 2010 ConnectDialog.class
3481 Sat Mar 13 08:58:44 IST 2010 Count.class
1377 Sat Mar 13 08:58:44 IST 2010 DataFileTable$1.class
954 Sat Mar 13 08:58:44 IST 2010 DataFileTable$2.class
954 Sat Mar 13 08:58:44 IST 2010 DataFileTable$3.class
591 Sat Mar 13 08:58:44 IST 2010 DataFileTable$4.class
8815 Sat Mar 13 08:58:44 IST 2010 DataFileTable.class
4141 Sat Mar 13 08:58:44 IST 2010 DataFileTableModel.class
900 Sat Mar 13 08:58:44 IST 2010 DownloadingDialog.class
479 Sat Mar 13 08:58:44 IST 2010 EmailClient$1.class
507 Sat Mar 13 08:58:44 IST 2010 EmailClient$10.class
507 Sat Mar 13 08:58:44 IST 2010 EmailClient$11.class
507 Sat Mar 13 08:58:44 IST 2010 EmailClient$12.class
506 Sat Mar 13 08:58:44 IST 2010 EmailClient$2.class
1296 Sun Feb 07 19:00:38 IST 2010 EmailClient$3$1.class
872 Sat Mar 13 08:58:44 IST 2010 EmailClient$3.class
1355 Sat Mar 13 08:58:44 IST 2010 EmailClient$4.class
984 Sat Mar 13 08:58:44 IST 2010 EmailClient$5.class
505 Sat Mar 13 08:58:44 IST 2010 EmailClient$6.class
1914 Sat Mar 13 08:58:44 IST 2010 EmailClient$7.class
553 Sat Mar 13 08:58:44 IST 2010 EmailClient$8.class
1259 Sat Mar 13 08:58:44 IST 2010 EmailClient$9.class
3355 Sat Mar 13 08:58:44 IST 2010 EmailClient$Checker.class
14459 Sat Mar 13 08:58:44 IST 2010 EmailClient.class
1993 Sat Mar 13 08:58:44 IST 2010 Learner.class
537 Sat Mar 13 08:58:44 IST 2010 MessageDialog$1.class
564 Sat Mar 13 08:58:44 IST 2010 MessageDialog$2.class
564 Sat Mar 13 08:58:44 IST 2010 MessageDialog$3.class
4696 Sat Mar 13 08:58:44 IST 2010 MessageDialog.class
2663 Sat Mar 13 08:58:44 IST 2010 MessagesTableModel.class
354 Thu Feb 25 07:25:44 IST 2010 WindowCloser.class
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The javaw.exe program that runs JAR files is flawed. Any exception or error thrown from the main method is shown with that specific error message. Try running the JAR file from the command line:
- open a command window
- go to the folder where the JAR file is located (use "cd folder" to go into a folder)
- execute the following command: "java -jar test2.jar"

This will show you the exact stack trace of the error or exception instead of consuming it and showing a (too) generic error message.
 
gayathri murugesan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D:\pro>java -jar test2.jar
Exception in thread "main" java.lang.NoClassDefFoundError: EmailClient
Caused by: java.lang.ClassNotFoundException: EmailClient
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: EmailClient . Program will exit.

 
gayathri murugesan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
before making the jar file i compiled an d ran the program .it worked properly. but when i make the jar file i am getting this CLASSNOTFOUNDEXCEPTION.


please help..

 
reply
    Bookmark Topic Watch Topic
  • New Topic