Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About JAR files...

 
Chris Stewart
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've packaged up a jar file with my classes and libs neatly placed in their directory structure. I've created a cmd file that will be used to call the main method of the application to start the application. I'm having trouble adding the libs within the jar to the classpath so my application can find and use them. Here is the code from my cmd file.

I know the SystemStart path is correct and that it takes an argument. When I run this script it gives me this.

Which tells me it isn't finding the lib files (the JavaMail jar files). Does anyone know the syntax for my classpath to add the jar files from inside my application jar file? Thanks for your time.
 
Pete Lyons
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
James,
It's easier if you make your jar file "executable" by adding this line to the META-INF/MANIFEST.MF file inside the jar:
Main-Class: com.home.rptsendmail.v2.SystemStart
and then run it with:
java -jar RptSendMail-2.0.0.jar
see The Jar File Tutorial
If you want to ship the javaMail stuff alongside your jar, use the manifest's Class-Path: entry like this (this may not be permissible by Sun though, so check the license carefully)
Download extensions are specified in the Class-Path header field in the manifest file of an applet, application, or another extension. A Class-Path header might look like this, for example:
Class-Path: servlet.jar infobus.jar acme/beans.jar
With this header, the classes in the files servlet.jar, infobus.jar, and acme/beans.jar will serve as extensions for purposes of the applet or application. The URLs in the Class-Path header are given relative to the URL of the JAR file of the applet or application.

Otherwise, just unjar all the classes you need and bundle them directly in your .jar (no nested jar files).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic