• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Another classpath question

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a stand alone app, public static void main(String[] args), that uses several other libraries (jars). I am able to get it to work, but listing all of the jar files in the classpath is a pain. How do I put everything including the extra jars in one jar and execute it and get my app to see all of the other jars it needs?

Most all of my experience is with j2ee. I have not done a stand alone app of this scope before.

Thanks,

Warren
 
Author
Posts: 3473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't have a jar inside another jar. If you use JRE 6 + you can just specify the folder name in the classpath. You can have a folder called lib and then refer to it in your script.
 
Warren Bell
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I have to list every jar in my classpath? There is no other way of doing this? My command line to execute this is very long. How does an executable jar work? The app in an executable jar may still need to access other outside jars. I just want to easily make changes to my app like adding another library and not have to worry about classpaths all the time. It would be nice to just copy a new jar of my app and execute it like a war file works in a servlet container.

Warren
 
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for Understanding class path wildcards
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds too difficult a question for beginners'. Moving.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

having trouble with external jars & classpath too , i stumbled upon a nice plugin for eclipse called Fat-Jar.

not sure if this is what you are looking for , but take a look


http://fjep.sourceforge.net/
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Warren Bell wrote:So, I have to list every jar in my classpath? There is no other way of doing this? My command line to execute this is very long. How does an executable jar work?


The manifest file has Class-Path attribute where you list all the jars you want to be able to reference. See the Sun Tutorial.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic