Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By wsaryada

Thread: how to import jar file

  1. #1
    Ashwin94 is offline Member
    Join Date
    Aug 2013
    Posts
    11
    Rep Power
    0

    Default how to import jar file

    I AM GETTING ERROR....................PLZ SOME ONE SOLVE............


    D:\java\proj>set classpath="D:\java\proj\pack\common-cli-1.2.jar\;"

    D:\java\proj>javac test4.java

    test4.java:4: error: package org.apache.commons.cli does not exist
    import org.apache.commons.cli.CommandLine;
    ^
    test4.java:5: error: package org.apache.commons.cli does not exist
    import org.apache.commons.cli.CommandLineParser;
    ^
    test4.java:6: error: package org.apache.commons.cli does not exist
    import org.apache.commons.cli.HelpFormatter;
    ^
    test4.java:7: error: package org.apache.commons.cli does not exist
    import org.apache.commons.cli.Option;
    ^

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: how to import jar file

    Try using the javac commands -cp option. For example:
    javac.exe -cp .;acm.jar;..\.;objectdraw.jar;comm.jar;mail.jar
    Last edited by Norm; 08-12-2013 at 02:56 AM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,712
    Rep Power
    5

    Default Re: how to import jar file

    What Norm says also works but if you must know what was wrong with the way you're doing it: the environmental variable name is CLASSPATH, not classpath (so all uppercase). Also a jar is not a directory, so it should probably be something like this:

    Java Code:
    set CLASSPATH="D:\java\proj\pack\common-cli-1.2.jar;."
    Note the dot I added to the end there, that means that the "current working directory" (IE. the directory you're in) is also on the classpath.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Ashwin94 is offline Member
    Join Date
    Aug 2013
    Posts
    11
    Rep Power
    0

    Default Re: how to import jar file

    i tried both still its not comin.......

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: how to import jar file

    Can you open a command prompt window, execute the javac command, copy the full contents of the window and pasted it here so we can see what happens?

    Are you sure the jar file has the missing packages? Have you looked inside the jar (use a zip file utility) to see what it contains?


    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    757
    Rep Power
    8

    Default Re: how to import jar file

    Maybe you supply the wrong jar file name? The Apache Commons library name is prefixed with "commons" not "common". Just a random guess :)
    gimbal2 likes this.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,712
    Rep Power
    5

    Default Re: how to import jar file

    You're probably right too.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 1
    Last Post: 11-20-2012, 04:41 AM
  2. How do I import a list file?
    By Codeless in forum New To Java
    Replies: 1
    Last Post: 11-14-2010, 02:36 PM
  3. Import data from file into a gui
    By SBL in forum AWT / Swing
    Replies: 5
    Last Post: 11-21-2009, 04:10 PM
  4. how to import xfdf file into the pdf file
    By jkrishnanvenkat in forum New To Java
    Replies: 3
    Last Post: 11-09-2009, 02:46 AM
  5. how to import war file with tomcat?
    By makpandian in forum NetBeans
    Replies: 0
    Last Post: 12-31-2008, 11:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •