I need to distribute my applctn by making a jar. My application references other jars which has been included in the "lib" folder. I have created the jar containing the class files and the lib folder. Now I need to execute my main class using the option java -jar <class-name>. But it doesnot seem to work as it throws an error saying the classes in the jar files contined in the lib folder cannot be found. Please help and Thanks in advance
So you have those JAR files in the lib directory inside your own JAR? That doesn't work - Java does not support loading classes from nested JAR files. You will have to keep the other JARs separate from your own JAR, but you do have to put them in the classpath that's specified the manifest file of your own JAR.
Thanks it worked i had to place the jars externally and refer them in the manifedt while creating the jar file.
you need to use the command using the followin command jar -cfm <file1> <file2> <class1.class> <class2.class> where file1=jar file name file2= file from which the manifest will be created file2 will have entry for "Class-Path:" which will contain path for the externally placed lib files. Hope this helps