Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another classpath question

 
Warren Bell
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
 
arulk pillai
Author
Ranch Hand
Posts: 3388
  • 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
 
James Tharakan
Ranch Hand
Posts: 580
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look for Understanding class path wildcards
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds too difficult a question for beginners'. Moving.
 
Yoav Weiss
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/
 
Tony Docherty
Bartender
Posts: 2989
59
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic