• Post Reply Bookmark Topic Watch Topic
  • New Topic

can't run log4j: class file problem  RSS feed

 
Jason Attin
Ranch Hand
Posts: 234
2
  • Mark post as helpful
  • send pies
  • 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]
 
John Joe
Ranch Hand
Posts: 358
2
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you added the dependencies ?
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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.
 
Knute Snortum
Sheriff
Posts: 3971
97
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!