• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Using Jar Files

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

See: The Java Tutorial - Lesson: Packaging Programs in JAR Files

If you don't want this, and you want to have your application in a single JAR, have a look at One-JAR.
 
Nadda Habba
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Hug your destiny! And hug this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic