Creation of jar file

Dear All,
     I am having three class files named first.class, second.class and third.class. I will run the fist.class as - java first. The first will call the second class. The second will in turn call the third class.
     I want to zip all the above said class files and put as a single jar file and run it as usual...how to do that??? I mean I dont want to keep all the class files as seperate ones...
My main method is present in the first class.
waiting for ur reply,
Sakthivel S.

http://java.sun.com/j2se/1.4.1/docs/guide/jar/index.html

Similar Messages

  • Help---- creation of jar file

    hi,
    i have developed a application with swing concept and mysql as my database... now i am trying to create jar file for my application... in the manifest file i have given like this:
    class-path: C:\Program Files\MySQL\mysql-connector-java-5.0.4-bin.jar;C:\Program Files\Java\jdk1.5.0\bin;
    Main-Class: Login
    but still it throws an exception that main class: could not be found:
    can any one help me...
    Thank u in advance..
    Abdul

    For a classpath it is easy to forget to add code]//.;[ to the classpath and you also want to add %CLASSPATH%; as well
    example classpath=.;%CLASSPATH%;...........rest of libs/jars the dot tells jvm to search current directory just like in DOS
    Sean

  • Problems with creation of JAR file

    Hi!
    I can't succeed in creating a JAR file for my application.
    I've followed the guide at http://java.sun.com/docs/books/tutorial/deployment/jar/basicsindex.html
    but apparently im doing something wrong....
    I've tried doing an extra Manifest file aswell as "Setting an Entry Point with the JAR Tool" as written in the guide. noen with success however :(
    I always get the error "Could not find the main class. Program will exit." from the JVM when I try to run my JAR file.
    Structure of my program:
    C:\searchpath\moresearchpath\projectname\src\
    inside src\ there are 3 packages called; "graphic", "client" and "server".
    I want to make a JAR file from the files in the "server" package. The "server" package consists of these following 4 files(and nothing more); "ClientHandler.java", "TestServer.java", "ServerModel.java", "ServerController.java".
    "TestServer.java" is my main class!
    This is an example of a command I've done in order to try to make a JAR file:
    "C:\searchPathToWhereJavaIsInstalled\jdk1.6.0\bin\jar cvfe sgwserver.jar server.TestServer server\*"
    This doesn't generate any error. However when I try to start the .jar I get following message "Could not find the main class. Program will exit."
    I've also tried creating manifest file manually but without success (with UTF-8 encoding and not double .txt ending on file)
    This is how the "Manifest.txt" file has looked when I've tried making one:
    Main-Class: server.TestServer
    I have used Netbeans 5.5 and Java SE 6 for development
    What am I doing wrong? Please help me :(

    If I try to run the one generated from Netbeans I get the following error message: "Failed to load Main-Class manifest attribute from C:\searchpath\moresearchPath\projectName\dist\projectName.jar"
    The thing is I need 2 JAR files, one that contains the files in the "server" package and one that has all other files. The other one is an applet and the files in "server" package are a standalone application.
    How do I get the standalone application's JAR file to work?

  • Creation of jar files

    i am using the command jar cvf HelloApplet.jar hello/HelloApplet*.class in my ms-dos prompt in windows xp, it displays message invalid command. Kindly help me how to create jar files in javafx in javafx sdk using dos prompt

    i did as you mentioned in the reply but another problem which is coming is as:
    C:\Program Files\JavaFX\javafx-sdk1.0\bin\hello>jar cvf HelloApplet.jar hello/He
    lloApplet*.class
    hello\HelloApplet*.class : no such file or directory
    added manifest
    the jar file is being created but the index.html file which uses it can't display it. can anyone also see this html file whether it is right or not also please someone tell me hoe to uase javafx in an html page.
    <html>
    <head>
    <title>Wiki</title>
    </head>
    <body>
    <h1>Wiki</h1>
    <script src="dtfx.js"></script>
    <script>
    javafx(
    archive: "HelloApplet.jar",
    draggable: true,
    width: 150,
    height: 100,
    code: "hello.HelloApplet",
    name: "Wiki"
    </script>
    </body>
    </html>

  • JAVADOCs creation for Jar files.

    hi,
    How can i create javadocs for a jar files. I tried extracting the jar file and then creating docs of it but it has 2 folder in which there are 8 folders each, so running javadocs for each folder would be too much. Is it possible to create javadocs for the jar files directly.

    hi,
    Can i get the xml4j javadocs as i have the jar and will have to use it. The IBM website says it has migrated to the xerces-j parser, but i will still be using the xml4j.jar. It would be grt if i can get that. Also if anyone can clarify if i can use the same javadocs bor both xml4j and Apache's Xerces-J.
    this is for the xerces.jar file. it would be grt
    grt if i could get it for xml4j.jar file
    http://www.alphaworks.ibm.com/tech/xml4j :
    XML4J is now available as Apache's Xerces-J
    Parser.

  • Avoiding creation of jar file

    Hi All,
    Is there a way to create a jar file, without a MANIFEST FILE included, using JAR command.
    Thanks

    Sorry for the late reply CeciNEstPasUnProgrammeur.
    I was just curious whether it is possible or not.
    Thanks!

  • How to run a jar file in a HTML page.

    Hi, i have created an applet that works with 2 or 3 classes, the i have done a Jar file and now i want to run the applet though a Html page, i have looked at many manuals and i have done the same as is said to create the Html file, but whe i want to see the page on the part of the applet nothing appears to me and when i go though the area of the applet with de mouse an error message apears saying that the clas XXXX (the main class of my applet) can't be instanced.
    Could someone tell me why is this? i need help or to see an example that works.
    Thanks

    Hi, i have created an applet that works with 2 or 3
    classes, the i have done a Jar file and now i want to
    run the applet though a Html page, i have looked at
    many manuals and i have done the same as is said to
    create the Html file, but whe i want to see the page
    on the part of the applet nothing appears to me and
    when i go though the area of the applet with de mouse
    an error message apears saying that the clas XXXX (the
    main class of my applet) can't be instanced.
    Could someone tell me why is this? i need help or to
    see an example that works.
    ThanksUse the archive parameter in the applet tag.
    e.g: <applet code="your_main_applet" width="256" height="256" archive="myjar.jar">
    Where myjar.jar is the actual jar file which contains all the user class files which are required to run this applet.
    For creation of jar files, please read the java tutorial in http://java.sun.com
    /Sreenivasa Kumar Majji.

  • From Where can i download  Jar Files for creation of adapter Module.

    From Where can i download these Jar Files.
    aii_af_mp.jar à the interface Module
    aii_af_ms_api.jar  à Dealing with payload and attachment
    aii_af_trace.jar à Writing Trace
    aii_af_svc.jar à Adapter Services
    aii_af_cpa.jar à Reading Channel Entries
    aii_af_ms_spi.jar
    aii_af_cci.jar 
    for creation of adapter Module.

    As k you basisn team,they will provided it.
    usually these jars files available in server, in usr.repositoy folder,if you have server level access then you can copy it else contact your basis team.
    or you can download it from service market place.
    Regards,
    Raj

  • Problem with creation of a jar file from inside a java program

    Hi,
    I am trying to create a jar file at runtime from within a java program.
    I am able to create a jar file just fine using:
    String[] jarArgs = new String[3];
    jarArgs[0] = "cvf";
    jarArgs[1] = "C:\temp\myjar.jar";
    jarArgs[2] = "C:\temp\this";
    sun.tools.jar.Main main1 = new sun.tools.jar.Main(System.out, System.err, "jar");
    main1.run(jarArgs);However, when I look at the jar it puts the absolute path to the files inside such as:
    C:\temp\this\is\my\package\Class.class
    instead of only this\is\my\package\Class.class
    When running the jar command from the command line it works just fine and I have the relative paths in my jar file.
    Does anyone have any experience with this and could help me out?
    Thanks in advance
    Edited by: mruf on Apr 11, 2008 1:51 AM

    Shouldn't jarArgs[2] = "-C C:\temp\this"

  • Problem  in jar file creation

    I have create the jar file, but it show the following error mesage since i start to run it.
    Java Virtual Machine Laugcher
    Failed to load the main class manifest attribute from
    E:\j2sdk1.4.2\bin\test.jar
    What the problem for this?
    my manifest.mf file contain the information
    Manifest-Version: 1.0
    Main-Class: mysystem.MainFrame
    note, my directory is javac mysystem/MainFrame.java to run

    What's the name of the manifest file in the jar file?
    What do you get when you do
    jar tvf test.jar

  • Regarding the creation of common jar file ......!

    Hi All ,
    I need to create a new Jar file which consists of the generic code which we can use for connecting to the database. The class in the jar file should have methods like u201CExecuteSelectu201D. u201CExecuteInsertu201D, u201CExecuteDeleteu201D and u201CExecuteUpdateu201D.  which  should pass the required parameters to these methods so that they can execute the corresponding query. My  UDF should use this class file and call the methods above to run any SQL statements.
    any one having any idea about how to create the above requirements .....?
    Thanks in advance
    Aziz

    Hi,
    >> class in the jar file should have methods like u201CExecuteSelectu201D. u201CExecuteInsertu201D, u201CExecuteDeleteu201D and u201CExecuteUpdate
    For developing your requirement, you can use Eclipse or any other IDE which is supported for writing Java codes. Write the codes of your requirement in IDE and compile it. Make a .jar file of classes. and then create a new Imported archive and upload your .jar file. Then relevent  class has to be declared in the import statement. This way you can use your all classes in UDF.
    Regards
    Aashish Sinha

  • Regarding jar file creation

    hi friends
    i created jar file using export in eclipse...Successfully created the jar file..but i want to include libarary files also with that jar..for example jdbc connector jar file with that jar..please help
    regards

    [Creating JAR file|http://java.sun.com/docs/books/tutorial/deployment/jar/build.html]

  • Jar file creation problem

    I have create the jar file, but it show the following error mesage since i start to run it.
    Java Virtual Machine Laugcher
    Failed to load the main class manifest attribute from
    E:\j2sdk1.4.2\bin\test.jar
    What the problem for this?
    my manifest.mf file contain the information
    Manifest-Version: 1.0
    Main-Class: mysystem.MainFrame
    note, my directory is javac mysystem/MainFrame.java to run

    Open the jar in WinZip (or any other).
    the mysystem directory should be in the root..

  • OSGI bundle creation using third party jar files

    Hi,
    I have a requirement to integrate our CQ5.5 based application with a third party. As part of this, I have to use some jar files. After lot of digging, I realised that the way to use external jar files is to create an OSGI bundle wrapping these jar files.
    So, I tried to do the same, but when I see the service details in system/console, I see errors. Can someone please suggest what could have gone wrong?
    I have to use 3 jar files. So, I placed them in lib folder as shown in the screenshot below.
    Ibuilt the bundle using .bnd file. It generated a jar file in install folder and I am able to to see its details in system/console/bundles. When I try to view details of the OSGI bundle that is installed, I see errors as follows:

    Here is my bnd file with all directives:
    Export-Package: *
    Import-Package: *
    Private-Package: *
    # Include-Resource:
    Bundle-Name: External Jar OSGI
    Bundle-Description: This OSGI bundle contains external jar file
    Bundle-SymbolicName: com.self.learning.externaljarosgi
    Bundle-Version: 1.0.0-SNAPSHOT
    Bundle-Activator: com.self.learning.osgi.oauth.Activator
    And here is what is shown in systems/console/bundle:
    Imported Packagesjavax.crypto from org.apache.felix.framework (0)
    javax.crypto.spec from org.apache.felix.framework (0)
    javax.servlet from cqse-httpservice (21)
    javax.servlet.http from cqse-httpservice (21)
    net.oauth -- Cannot be resolved
    net.oauth.client -- Cannot be resolved
    net.oauth.client.httpclient3 -- Cannot be resolved
    net.oauth.client.httpclient4 -- Cannot be resolved
    net.oauth.server -- Cannot be resolved
    net.oauth.signature -- Cannot be resolved
    org.apache.commons.codec.binary from org.apache.commons.codec (46)
    org.apache.commons.httpclient from com.day.commons.osgi.wrapper.commons-httpclient (77)
    org.apache.commons.httpclient.methods from com.day.commons.osgi.wrapper.commons-httpclient (77)
    org.apache.http -- Cannot be resolved
    org.apache.http.client -- Cannot be resolved
    org.apache.http.client.methods -- Cannot be resolved
    org.apache.http.entity -- Cannot be resolved
    org.apache.http.impl.client -- Cannot be resolved
    org.apache.http.params -- Cannot be resolved
    org.apache.http.util -- Cannot be resolved
    org.osgi.framework from org.apache.felix.framework (0)
    org.slf4j from slf4j.api (11)
    Regarding Export-Package, I know the function, class and its package I need to use. Would it be fine if I just export that package instead of using '*'? In such case, if this has dependency on some function in one of the 4 jar files I need to use, how does it get resolved? Do I need to Export those packages as well?

  • Adding JAR file to project

    Hi All
    How can i add jar to my project environment.
    Actually what i did was.
    Created one folder called "JavaWork" like d:\JavaWork
    and put the jar file into this folder and wrote a test class which is importing some classes from the jar file.
    how to use jar ? Please someone help me.
    Thanks in advance
    Shan

    `man jar`
    jar(1) jar(1)
    NAME
    jar - Java archive tool
    SYNOPSIS
    jar [ -C ] [ c ] [ f ] [ i ] [ M ] [ m ] [ O ] [ t ] [ u ]
    [ v ]
    [ x file ] [ manifest-file ] destination input-file
    [ input-files ]
    DESCRIPTION
    The jar tool is a Java application that combines multiple
    files into a single JAR archive file. It is also a gen-
    eral-purpose archiving and compression tool, based on ZIP
    and the ZLIB compression format. However, jar was
    designed mainly to facilitate the packaging of Java
    applets or applications into a single archive. When the
    components of an applet or application (.class files,
    images and sounds) are combined into a single archive,
    they can be downloaded by a Java agent (like a browser) in
    a single HTTP transaction, rather than require a new con-
    nection for each piece. This dramatically improves down-
    load time. The jar tool also compresses files, which fur-
    ther improves download time. In addition, it allows indi-
    vidual entries in a file to be signed by the applet author
    so that their origins can be authenticated. The syntax
    for the jar tool is almost identical to the syntax for the
    tar(1) command. A jar archive can be used as a class path
    entry, whether or not it is compressed.
    The three types of input files for the jar tool are:
    o Manifest file (optional)
    o Destination jar file
    o Files to be archived
    Typical usage is:
    example% jar cf myjarfile *.class
    In this example, all the class files in the current direc-
    tory are placed in the file named myjarfile. A manifest
    file is automatically generated by the jar tool and is
    always the first entry in the jar file. By default, it is
    named META-INF/MANIFEST.MF. The manifest file is the
    place where any meta-information about the archive is
    stored. Refer to the Manifest Format in the SEE ALSO sec-
    tion for details about how meta-information is stored in
    the manifest file.
    To use a pre-existing manifest file to create a new jar
    archive, specify the old manifest file with the m option:
    example% jar cmf myManifestFile myJarFile *.class
    When you specify cfm instead of cmf (that is, you invert
    the order of the m and f options), you need to specify the
    name of the jar archive first, followed by the name of the
    manifest file:
    example% jar cfm myJarFile myManifestFile *.class
    The manifest uses RFC822 ASCII format, so it is easy to
    view and process manifest-file contents.
    OPTIONS
    The following options are supported:
    -C Changes directories during execution of the jar com-
    mand. For example:
    example% jar uf foo.jar -C classes *
    c Creates a new or empty archive on the standard out-
    put.
    f The second argument specifies a jar file to process.
    In the case of creation, this refers to the name of
    the jar file to be created (instead of on stdout).
    For table or xtract, the second argument identifies
    the jar file to be listed or extracted.
    i Generates index information for the specified jar
    file and its dependent jar files. For example,
    example% jar i foo.jar
    would generate an INDEX.LIST file in foo.jar which con-
    tains location information for each package in foo.jar and
    all the jar files specified in foo.jar's Class-Path
    attribute.
    M Does not create a manifest file for the entries.
    m Includes manifest information from specified pre-
    existing manifest file. Example use:
    example% jar cmf myManifestFile myJarFile *.class
    You can add special-purpose name-value attribute
    headers to the manifest file that are not contained
    in the default manifest. Examples of such headers
    are those for vendor information, version informa-
    tion, package sealing, and headers to make JAR-bun-
    dled applications executable. See the JAR Files
    trail in the Java Tutorial and the JRE Notes for
    Developers web page for examples of using the m
    option.
    O Stores only, without using ZIP compression.
    t Lists the table of contents from standard output.
    u Updates an existing JAR file by adding files or
    changing the manifest. For example:
    example% jar uf foo.jar foo.class
    adds the file foo.class to the existing JAR file
    foo.jar, and
    example% jar umf foo.jar
    updates foo.jar's manifest with the information in
    manifest.
    v Generates verbose output on stderr.
    x file
    Extracts all files, or just the named files, from
    standard input. If file is omitted, then all files
    are extracted; otherwise, only the specified file or
    files are extracted.
    If any of the files is a directory, then that direc-
    tory is processed recursively.
    EXAMPLES
    To add all of the files in a particular directory to an
    archive:
    example% ls
    0.au 3.au 6.au 9.au at_work.gif
    1.au 4.au 7.au Animator.class monkey.jpg
    e.au 5.au 8.au Wave.class spacemusic.au
    example% jar cvf bundle.jar *
    adding: 0.au
    adding: 1.au
    adding: 2.au
    adding: 3.au
    adding: 4.au
    adding: 5.au
    adding: 6.au
    adding: 7.au
    adding: 8.au
    adding: 9.au
    adding: Animator.class
    adding: Wave.class
    adding: at_work.gif
    adding: monkey.jpg
    adding: spacemusic.au
    example%
    If you already have subdirectories for images, audio
    files, and classes that already exist in an HTML direc-
    tory, use jar to archive each directory to a single jar
    file:
    example% ls
    audio classes images
    example% jar cvf bundle.jar audio classes images
    adding: audio/1.au
    adding: audio/2.au
    adding: audio/3.au
    adding: audio/spacemusic.au
    adding: classes/Animator.class
    adding: classes/Wave.class
    adding: images/monkey.jpg
    adding: images/at_work.gif
    example% ls -l
    total 142
    drwxr-xr-x 2 brown green 512 Aug 1 22:33 audio
    -rw-r--r-- 1 brown green 68677 Aug 1 22:36 bundle.jar
    drwxr-xr-x 2 brown green 512 Aug 1 22:26 classes
    drwxr-xr-x 2 brown green 512 Aug 1 22:25 images
    example%
    To see the entry names in the jar file using the jar tool
    and the t option:
    example% ls
    audio bundle.jar classes images
    example% jar tf bundle.jar
    META-INF/MANIFEST.MF
    audio/1.au
    audio/2.au
    audio/3.au
    audio/spacemusic.au
    classes/Animator.class
    classes/Wave.class
    images/monkey.jpg
    images/at_work.gif
    example%
    To display more information about the files in the
    archive, such as their size and last modified date, use
    the v option:
    example% jar tvf bundle.jar
    145 Thu Aug 01 22:27:00 PDT 1996 META-INF/MANIFEST.MF
    946 Thu Aug 01 22:24:22 PDT 1996 audio/1.au
    1039 Thu Aug 01 22:24:22 PDT 1996 audio/2.au
    993 Thu Aug 01 22:24:22 PDT 1996 audio/3.au
    48072 Thu Aug 01 22:24:23 PDT 1996 audio/spacemusic.au
    16711 Thu Aug 01 22:25:50 PDT 1996 classes/Animator.class
    3368 Thu Aug 01 22:26:02 PDT 1996 classes/Wave.class
    12809 Thu Aug 01 22:24:48 PDT 1996 images/monkey.jpg
    527 Thu Aug 01 22:25:20 PDT 1996 images/at_work.gif
    example%
    If you bundled a stock trade application (applet) into the
    following jar files,
    main.jar buy.jar sell.jar other.jar
    and you specified the Class-Path attribute in main.jar's
    manifest as
    Class-Path: buy.jar sell.jar other.jar
    then you can use the i option to speed up your applica-
    tion's class loading time:
    example$ jar i main.jar
    An INDEX.LIST file is inserted in the META-INF directory
    which will enable the application class loader to download
    the right jar files when it is searching for classes or
    resources.
    SEE ALSO
    keytool(1)
    JAR Files @
    http://java.sun.com/docs/books/tutorial/jar/
    JRE Notes @
    http://java.sun.com/j2se/1.3/runtime.html#exam-
    ple
    JAR Guide @
    http://java.sun.com/j2se/1.3/docs/guide/jar/index.html
    For information on related topics, use the search link @
    http://java.sun.com/
    13 June 2000 jar(1)

Maybe you are looking for

  • Having problem implementing array in code?

    I am trying to write a code that will ask the user to either enter in a name of a reds baseball player, a batting average, or a slugging percentage. When this is entered the name of that corresponding player will pop up along with his stats. The code

  • Duplex Printing from the web with a Macintosh

    I have a MacBook Pro running OSX.5.8 and an HP printer Photosmart C309a.  I have not been able to use duplex printing from the web.  Any suggestions on how I can achieve this?  It's the reason I bought this particular machine.

  • Will a bluetooth adapter work with AirPort

    Hey Ladies and Gents, If I were to buy a bluetooth adapter for an iPod Classic, will it communicate with an AirPort system? My main goal is to send music to my home stereo from my iPod wirelessly. Is this possible? Thanks for you help, Jason

  • BIG PSD and slow Progress Bar!

    To open a 200meg PSD file in CS3 takes about 20 secs, I get this progress bar come up saying Reading Photoshop Format... is this normal? I have a fast P4 processor, 2 gigs of Ram and large separate hardrive I'm using as the scrtch disk. I am curious

  • CUCm , UCCX & QM upgrading

    we have the following :          -CUCM  7.0.2.20000-5      -UCCX   7.0(1)SR05_Build504      -QM      2.6.2.7 we have to upgrade all of these components to 9.X so how should i do the windows to linux upgrade for the CUCM and UCCX and what is the upgra