• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jar issues

 
Adrian Perry
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow ranchers

I have this class file that is used to send mails. This file requires 2 jars, activation.jar and mail.jar. Both these jars are included in the classpath.
This classfile runs perfectly when i run from the cmd or from eclipse.

But my requirement is that i need to make a jar file of the classfile. I have taken all the required steps while creating the jar file.
I created a manifest.txt file and it has 2 entries, Main-Class and
Class-Path. I have created jars using both cmd and eclipse. When I run the jar file i get the error

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Authenticator

This error i get for both the jars i have created one through cmd and the other through eclipse. javax/mail/Authenticator
This class is there in mail.jar, that i have included in the classpath.

I dont know why i am getting this error. When i run this classfile through cmd it runs fine, but when i run the jar file, it gives me the above error.

Please comment.
Thanks in advance
[ November 08, 2008: Message edited by: Adrian Perry ]
 
Campbell Ritchie
Sheriff
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you get javax.mail.Authenticator from? I can't find it in the API. It might be a J2EE class, in which case you would have to install J2EE.
 
Adrian Perry
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

javax.mail.Authenticator is right inside mail.jar file. It is lying inside mail package that is inside javax package.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you execute your command to run your JAR file are the mail.jar and activation.jar files in the same path? So if you did an ls/dir you would see

yourjar.jar
mail.jar
acitivation.jar

If not then your application won't load them in the classpath as it won't be able to find the JAR files.
 
Adrian Perry
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Issue solved?

I knew it was something obvious. My jar could not see the other jars. The reason being, there is file called Manifest.txt, in which you specify 2 parameters, in case your jar file has a main class and the path of other jar files that are required to run the main jar file.

Eg.

Manifest.txt
Main-Class: abc.XYZ
Class-Path: a.jar b.jar dir/c.jar

The error that i was making was that i was separating the jars using ";" and they have to separated using a "space".

Eg.
This is what i was doing
Class-Path: a.jar;b.jar;dir/c.jar
This is what was supposed to be done
Class-Path: a.jar b.jar dir/c.jar

Once that was done, my main jar could see the other jars.

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic