Solved

Java and Jar files

Posted on 2004-08-27
5
171 Views
Last Modified: 2010-03-31
Hi,
   I've written a small app that uses data stored in  important.jar

   This is in my classpath so everything works nicely. Now I want to package up my app into  mywork.jar - but of course when I run it, it complains about not being able to find the files from important.jar

   Is there an easy way to put them all in the same jar file?  I really only want to give users a single file to work with instead of a small collection :)


thanks in advance!
0
Comment
Question by:petepalmer
  • 2
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
Comment Utility
Assuming you want to create an executable jar, then add a Class-Path attribute to your jars manifest to specify the (relative) location of the other required jar

eg. if important.jar is in same directory then add:

Class-Path: important.jar
0
 
LVL 24

Expert Comment

by:sciuriware
Comment Utility
Why not bundle everything together in ONE jar?
;JOOP!
0
 
LVL 1

Author Comment

by:petepalmer
Comment Utility
I was hoping there was a way to do it with just one jar as opposed to two. The reason I don't want to take the files out of important.jar is that it's maintained by a friend of mine so I want it to be easy to update. Granted if I use classpath upgrading is simplicity itself - you just copy over the new jar file... but is there no other way? :)


0
 
LVL 92

Expert Comment

by:objects
Comment Utility
how can you do it with one jar, but without taking the files out of important.jar :)
If you use the appraoch I suggested above then there is no change required to the classpath.
0
 
LVL 1

Author Comment

by:petepalmer
Comment Utility
I couldn't think of another way either.... couldn't find anything in the docs... but just hoped I was being thick :)

Ah well, two jar files it is then! :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now