Results 1 to 11 of 11
  1. #1
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Unhappy Adding a .jar file (log4j)

    Hi all, ive got a problem relating to the log4j.jar file (I suppose it would be the same problem regardless of what the .jar file is).

    I created a library based off the log4j.jar file, and the logging works and everything runs smoothly on my laptop. However, when I use the project on another computer, i am prompted to change the filepath of the log4j.jar file.

    The strange thing is that it's in the classpath, and proof of that is that it's generated in my dist/lib folder when clean and build is selected.

    Any suggestions?

    Thanks!

  2. #2
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by SeanC View Post
    However, when I use the project on another computer, i am prompted to change the filepath of the log4j.jar file.
    What really happens here?

    Can your compiler see dist/lib folder at running time?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  3. #3
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    I'm not too sure. What I do is open the whole project from netbeans, and then it prompts me to choose the log4j.jar manually as it cannot find it :/

  4. #4
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Can you try putting your log4j.jar inside the folder where all your other jar files reside?

    The 'dist' folders are usually manipulated by the batch files or build files and used to generate the jars which are then put in place where the application can use it.

    May be putting your log4j.jar inside the folder [may be 'lib' or something] where other jar files are present, can resolve your issue.

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  5. #5
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    lib is actually found in the dist folder, and there are 2 other jar files generated in there - JUnit 4.5 and something else containing the word 'beans' in it. I'm really not seeing what the problem is :/

  6. #6
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by SeanC View Post
    lib is actually found in the dist folder, and there are 2 other jar files generated in there - JUnit 4.5 and something else containing the word 'beans' in it. I'm really not seeing what the problem is :/
    Is your code using any classes from those 2 jar files? Are those jar files working as expected?

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  7. #7
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    Yes, I'm using the JUnit 4.5 .jar file for sure as ive got a bunch of unit tests - the unit tests work when run individually, however if I right-click the project it netbeans and choose 'Test', then i get a bunch of classNotFoundException errors for the test classes. It seems strange though as the tests run if i test the 'test classes' individually.

  8. #8
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Try one thing, delete the JUnit 4.5.jar file and re-run the tests. That will confirm whether that was the same jar file which was getting referenced or not.

    Your "classNotFoundException" stuff is pointing to the class path issue. Make sure that you have set that correctly.

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  9. #9
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    Hi, yes ive removed the JUnit.jar file and you're right - the tests still ran properly (although the previous error when testing the whole project is still present).

    Am I carrying out the correct steps for adding log4j to my classpath? :

    -log4j is saved somewhere on my computer
    -I go on Tools > Libraries (in netbeans) and Create a new library which I call log4j.
    -I choose the filepath of the log4j.jar which is saved on my computer, and do the same under the sources tab.
    -Next, I right click my project, select properties and under the 'libraries' category, I choose 'Add Library' and add log4j. This is added to the 'Compile' tab. Ive also tried adding it to all the tabs, but had no luck.

  10. #10
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    I am not a Netbeans user for sure. But tried to find out on internet.

    Here are the links that explains some details: Including Jars In Jar In NetBeans and Discussion On Oracle Forum.

    See if that can help, or else as you know this is pretty much missing jar issue. You might need to consult with our universal friend Google.

    Hope that helps,

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  11. #11
    SeanC is offline Member
    Join Date
    Aug 2010
    Posts
    24
    Rep Power
    0

    Default

    Hi, thanks but unfortunately those articles did not provide much help as they explain how to make the jar work when the program is built - which is not my problem. My problem is that when I open the project to edit it etc, log4j is not found. To run it from the .jar, it is fine.

Similar Threads

  1. Replies: 0
    Last Post: 07-15-2010, 01:23 PM
  2. Replies: 1
    Last Post: 03-31-2010, 08:04 PM
  3. log4j file location
    By Netzilla in forum New To Java
    Replies: 0
    Last Post: 03-17-2010, 03:00 PM
  4. Log4j - setting up name of log file
    By Virkant Pawar in forum New To Java
    Replies: 3
    Last Post: 06-03-2008, 07:39 AM

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
  •