aspose file tools*
The moose likes Beginning Java and the fly likes About JAR files... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "About JAR files..." Watch "About JAR files..." New topic
Author

About JAR files...

Chris Stewart
Ranch Hand

Joined: Sep 14, 2002
Posts: 184
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

Joined: Aug 18, 2002
Posts: 109
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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About JAR files...
 
Similar Threads
Need a little bit of help
WebSphere app server, shared libs and class files
find source code through Jar file.
Intermediate/Advanced Java Users. Pl help with static profilers (PMD)
java.lang.ClassNotFoundException: org.hsqldb.jdbcDriver