how to create a jar file?

Posted on 2005-04-17
Last Modified: 2010-03-31
how do i package my program so that all my classes, images are in one file. I want to be able to double click on it and it to run on a java runtime enviroment.

I am also using jdbc connecter, do i need to put this is the package also?
Question by:tegz
    LVL 25

    Expert Comment

    LVL 25

    Expert Comment

    So, for example, at the command line, you need to move into the directory with your files, e.g:

       CD c:\directory\with\my\files

    Then, run something like this:

       JAR cf MyProgram.jar "inputFile1.class" "inputFile2.class" "image1.gif"

    Author Comment

    im using: mysql-connector-java-3.0.11-stable-bin.jar

    how do i put that in there too?
    LVL 25

    Expert Comment

    erm.. try this:

       JAR cf MyProgram.jar "inputFile1.class" "inputFile2.class" "image1.gif" "mysql-connector-java-3.0.11-stable-bin.jar"

    LVL 92

    Accepted Solution

    > im using: mysql-connector-java-3.0.11-stable-bin.jar
    > how do i put that in there too?

    You'll need to supply that jar seperately and reference it in the Class-Path: attribute in your MANIFEST
    LVL 15

    Expert Comment

    You can use this library
    to supported executable jar that includes nested jars.
    There is an eclipse plugin that uses this library at
    LVL 92

    Expert Comment

    But it will run fine with the jdbc driver jar distributed seperately. This also reduces the size of your applications jar.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
    Video by: Michael
    Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
    The viewer will learn how to implement Singleton Design Pattern in Java.

    734 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

    22 Experts available now in Live!

    Get 1:1 Help Now