This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Exporting to jar file in eclipse  RSS feed

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have an application in eclipse that has mail.jar and activation.jar added to its build path.

When I export the project into a jar file (windows xp) and run it, I get:

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

I'm not sure how it works, but I guess its using the java installed on pc which doesn't know about those 2 jars.
But they are exported in the jar file, so I thought it might work.

Is there anyway to fix this so I can run this jar on any computer that has java 1.6 installed? Thanks for any help.
 
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should not put JAR dependencies in your JAR file. You should put them all in the classpath when executing your application.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt while exporting project to jar in eclipse, it will include the external jar files in it.
The wizard shows it will only include source files, class files and classpaths.
Where as you can use other options like
1) If its hard and fast to build it through eclipse. You can use eclipse plugin called as Fat-Jar. Find more information from this link Fat Jar Eclipse Plugin
2) My suggestion to your Apache Ant to build or export your project into runnable jar file.


colin shuker wrote:Hi, I have an application in eclipse that has mail.jar and activation.jar added to its build path.

When I export the project into a jar file (windows xp) and run it, I get:

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

I'm not sure how it works, but I guess its using the java installed on pc which doesn't know about those 2 jars.
But they are exported in the jar file, so I thought it might work.

Is there anyway to fix this so I can run this jar on any computer that has java 1.6 installed? Thanks for any help.

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in gererally java.lang.NoClassDefFoundError is caused by JVM can't found the binary class file on runtime, JDK 1.5 does not include mail.jar and activation.jar in their standard install library. So you need invoke the two jar to your classpath when run java application.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I didn't wanna mess around with changing classpaths, so I used the Fat Jar, and it works well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!