• 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

ClassNotFoundException on main class in executable Jar file

 
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having a problem getting an application to run when packaged as an executable Jar file (java -jar MyJar.jar).
The application needs to reference an external Jar file (javamail-1.4's mail.jar). When I include that Jar on the Class-Path attribute of the Manifext.mf file, then I get a ClassNotFoundException on my main class. Without the class-path entry, my main class is found just fine (but of course it can't find the javamail stuff...).

First, here is the structure of my application's Jar file:


Here is the contents of my meta-inf/Manifest.mf file:



When the Manifest.mf file includes a Class-Path entry, is there something special I need to do to get the classes in my Jar on the class path as well?

I'm assuming I'm doing something silly, but after pouring over several tutorials/examples, I just don't see it.

Thanks,
 
Mark E Hansen
Ranch Hand
Posts: 650
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I decided to try copying the external jar into a directory relative to the location of my application's Jar file and changing the Class-Path entry in the Manifest.mf file accordingly, and it now works. Perhaps the Class-Path entry of the Manifest.mf file can't accept full-paths (or Windows full-paths)?

If there's a way to have my application refer to an external Jar that is referenced via a full Windows path, I would sure appreciate knowing how to do it. I would rather not make copies of the external Jars if I can help it.

Thanks,
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you noticed that MS Windows file system uses back slash ("\") character instead of slash ("/") !?

I'm not sure, but you can try it and also you can use extension mechanism...
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Esmaeil Ashrafi wrote:Did you noticed that MS Windows file system uses back slash ("\") character instead of slash ("/") !?


No, that's not correct. The backslash is Windows specific, the forward slash is universal. Open a command prompt in Windows and try a cd command with a forward slash to see for yourself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic