Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

create an exectuable jar file whose classes reference another jar in Eclipse

Thread view: 
puzzlecracker - 19 Dec 2005 18:48 GMT
I have jar file with main class. The classes in that jar refernce (aka
import ) class from different  jar. Thus when I click on the execuable
jar, iI get noclassfound.  How to create executable that will have that
jar in its classpath.
Thanks.

I dont want to merge both jars.
Jean-Francois Briere - 19 Dec 2005 19:55 GMT
Specify the extra jar files in the META-INF/MANIFEST.MF file:

Class-Path: file1.jar file2.jar ...

Regards
puzzlecracker - 19 Dec 2005 21:01 GMT
> Specify the extra jar files in the META-INF/MANIFEST.MF file:
>
> Class-Path: file1.jar file2.jar ...
>
> Regards

is there a way to do it through exclipse?
it seems to create metafile witout classpath?

Thanks.
jason - 20 Dec 2005 00:18 GMT
AFAIK, you have to save off the manifest file that it generates,
manually edit it, and then tell the jar export wizard to use your
custom manifest file.
Jean-Francois Briere - 20 Dec 2005 03:33 GMT
You could also create at the project root the following create_jar.xml
file:

<project name="create_jar" default="create_jar">
    <target name="create_jar">
        <mkdir dir="jar" />
       <jar destfile="jar/myFile.jar">
           <fileset dir="bin" />
           <manifest>
               <attribute name="Main-Class" value="MyClass" />
               <attribute name="Class-Path" value="externalFile1.jar
externalFile2.jar" />
           </manifest>
       </jar>
      </target>
</project>

(This will create the jar/myFile.jar jar file
with the files located in bin sub-folder,
with MyClass as main class,
with externalFile1.jar and externalFile2.jar as jars in the search
class path).

Of course, you must change the values appropriately for your project.

When you're ready to create the jar file, simply right-click on the xml
file
in the package explorer window, then select 'Run As' -> '1 Ant Build'

Regards


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.