Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

can't run log4j: class file problem

 
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys, I'm trying to look at log4j and I followed this tutorial http://www.javawebtutor.com/articles/log4j/log4j-example-using-properties-file.php
After downloading the log4j files and added the jar to the java build path I created the following class as instructed:


But I get these two errors:
lem

Line 12 refers to this


See screenshot for what I have in the Java Build Path. Ah, and I'm on Linux, STS 3.8.4
thanks
java_build_path.png
[Thumbnail for java_build_path.png]
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you added the dependencies ?
 
Marshal
Posts: 3718
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the problem is with your jar file.  I tried the same one you used, and found the same issue.

Try using the latest of the Log4j 1.x jar - available here.
 
Sheriff
Posts: 7111
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Off topic, but you don't need both the JDK and JavaSE as your configured JRE; one will do.
 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done what Ron McLeod suggested and it works. That's rather interesting, the first time I downloaded the log files from the official apache website, so any idea why it's not working? That seems really odd.

Knute Snortum: I tend to use the jdk, it feels better, but in actual fact I didn't know that I could use one or the other

John Joe: what dependencies where please?
 
Ron McLeod
Marshal
Posts: 3718
533
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jason Attin wrote:I've done what Ron McLeod suggested and it works. That's rather interesting, the first time I downloaded the log files from the official apache website, so any idea why it's not working? That seems really odd.


Having api in the name of the jar that you originally tried (log4j-1.2-api-2.8.2.jar) makes me think that it might have had interfaces only and no actual implementation.
 
Sheriff
Posts: 22509
122
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreover, that JAR is part of Log4J 2. That's a complete redesign based (like SLF4J) on interface, and then one or more implementations. Ron linked to the old (but still very popular) Log4J 1 JAR.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic