DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Christer Nordvik Guest

    Packaging a files to JAR?

    How do I package all my files to a single jar file? I have libraries that
    are jar files themselves.

    My file:
    prog.class

    Includes:
    demo.jar

    I have tried: "jar cvm myNewJarFile.jar prog.class demo.jar" , but that
    didn't work when I tried to run my program.


    -Christer



  2. #2
    Paul Clapham Guest

    Re: Packaging a files to JAR?

    I don't know why you need to do that, but if you want to then you do this:

    1. Take all the files out of demo.jar and put them into a directory
    somewhere.

    2. Put prog.class and all files in that new directory into the new jar
    file.

    PC2

    "Christer Nordvik" <cn@iceinternational.com> wrote in message
    news:3bc3fdda@news.devx.com...
    > How do I package all my files to a single jar file? I have libraries that
    > are jar files themselves.
    >
    > My file:
    > prog.class
    >
    > Includes:
    > demo.jar
    >
    > I have tried: "jar cvm myNewJarFile.jar prog.class demo.jar" , but that
    > didn't work when I tried to run my program.
    >
    >
    > -Christer
    >
    >




  3. #3
    Greg Guest

    Re: Packaging a files to JAR?


    Christer,

    You almost had it right. You want to use "jar cf myNewJarFile.jar prog.class
    demo.jar". The "f" flag is so you can specify the jar filename.

    I found that the jar file within the jar file could not be used in the classpath
    though. What you might want to do is to extract the jar archive with "jar
    xf jarfile.jar" and put the class files into your jarfile.

    I hope that this helps you out.

    Greg


    "Christer Nordvik" <cn@iceinternational.com> wrote:
    >How do I package all my files to a single jar file? I have libraries that
    >are jar files themselves.
    >
    >My file:
    >prog.class
    >
    >Includes:
    >demo.jar
    >
    >I have tried: "jar cvm myNewJarFile.jar prog.class demo.jar" , but that
    >didn't work when I tried to run my program.
    >
    >
    >-Christer
    >
    >



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links