This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Include other jar files in project Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Include other jar files in project" Watch "Include other jar files in project" New topic
Author

Include other jar files in project

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi!

I think this is a rather simple question but I can get it right.
I need to include antoher jar file in my projects so that when a user downloads my jar no classpath needs to be set. There are altso properties files that a user needs to edit but they must reside outside the jars.

// Mathias


SCJP1.4
Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

What do you mean by 'include' and 'projects'?
Sidd Kulk
Ranch Hand

Joined: Feb 20, 2007
Posts: 152
From your query, it seems that you want the user to be able to download your jar file, using some protocol. I don't think you need to do anything, you can just set the content type of your JSP as jar. I am not sure, but it should work.

It would be helpful for us if you can elaborate as to exactly what you are trying to do.

Njoy!!
Sid
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
I have compiled a jar file with my classes. It import classes from another jar.
How can I make it one clickable jar file for distribution without making a lot of bat files or sh files?

And most important, without messing with user classpath?
[ April 19, 2007: Message edited by: Mathias Nilsson ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35220
    
    7
Does it need to be one jar file? The manifest of a jar file can declare a classpath that includes other jar files. So if you distributed a zip file that unzips to a directory full of jars, everything should work nicely. You could even include the main class in all the jars, thus ensuring that it doesn't matter which jar file is double-clicked.


Android appsImageJ pluginsJava web charts
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Ok I there any short example on how to do this?
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12907
    
    3

Have a look at this part of The Java Tutorial:
Lesson: Packaging Programs in JAR Files


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: Include other jar files in project
 
Similar Threads
difference between user variables and system variables
how to include external jars in single jar
JAR Execuatable
The Request Resource is not available.
path to db.db file