This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Another classpath question  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • 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: 3443
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Look for Understanding class path wildcards
 
Marshal
Posts: 64496
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds too difficult a question for beginners'. Moving.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!