Results 1 to 5 of 5
  1. #1
    alexandros is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Question Jar utility and log4j

    Hi, everyone.

    I'm new to java and I have this utility java project in Netbeans to which I want to add log4j. The log4j jar is not getting packed inside the utility when this one gets built. Either way I wouln't know where to put it.
    A
    Java Code:
    NoClassDefFoundError: org/apache/log4j/Logger
    message is thrown every time I try to run the main class. I do have the log4j.xml inside the utility JAR, in a default package/folder.
    I run the utlity with classic java -jar.

    Any help would appreciated.

    Thank you.
    Last edited by alexandros; 11-01-2013 at 07:54 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default Re: Jar utility and log4j

    The log4j jar needs to be on the classpath when the program is executed. One way is to use the manifest file's Class-Path: entry with the log4j jar.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    alexandros is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

    Default Re: Jar utility and log4j

    Hi, thank you for your response.

    My MANIFEST.MF says:
    Java Code:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 1.6.0_01-b06 (Sun Microsystems Inc.)
    Main-Class: dc.decisor3Batch.util.BatchCopier
    Class-Path: . lib/log4j-1.2.16.jar
    X-COMMENT: Main-Class will be added automatically by build
    And when I unzip the utility jar there are META-INF, dc, lib folders and log4j.xml

    lib folder has the log4j jar

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,882
    Rep Power
    25

    Default Re: Jar utility and log4j

    When you execute the command: java -jar THEJARFILE.jar
    does the folder that holds the file: THEJARFILE.jar contain the lib folder that contains the log4j-1.2.16.jar file?

    See: http://docs.oracle.com/javase/tutori...r/downman.html
    Last edited by Norm; 11-01-2013 at 08:33 PM.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    alexandros is offline Member
    Join Date
    Sep 2012
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Replies: 2
    Last Post: 04-02-2013, 02:04 PM
  2. Replies: 6
    Last Post: 02-04-2013, 12:14 PM
  3. Synchronization utility to manage locks
    By JSL5101 in forum Advanced Java
    Replies: 1
    Last Post: 05-07-2011, 06:43 PM
  4. Replies: 1
    Last Post: 09-20-2010, 09:32 AM
  5. XML compare utility
    By JMayura in forum Advanced Java
    Replies: 0
    Last Post: 06-08-2010, 02:05 PM

Tags for this Thread

Posting Permissions

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