setting classpath for slf4j for java compiling
This dependency is the api:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
You need the slf4j-api.jar in your classpath for compiling, not the slf4j-log4j12.jar.
It worked in maven because the binding-lib (slf4j-log4j12) has a dependency on the api and thus maven loads that as well, without you explicitly defining it as a dependency.
eagertoLearn
Updated on July 09, 2022Comments
-
eagertoLearn almost 2 years
I am having a problem setting up the
classpath
forslf4j
forcompiling java files
. I tried two ways: 1. provide theclasspath
incommand line
javac -cp /Users/page/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar src/main/java/com/scg/domain/*.java src/main/java/com/scg/util/*.java
This gave the following error:
src/main/java/com/scg/util/ListFactory.java:8: error: package org.slf4j does not exist import org.slf4j.Logger; ^ src/main/java/com/scg/util/ListFactory.java:9: error: package org.slf4j does not exist import org.slf4j.LoggerFactory; ...../long error message
- I tried to
export
theCLASSPATH
to myenv
variable.
export CLASSPATH=/Users/page/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar
This did not help either and resulted in same error, when I tried
javac src/main/java/com/scg/domain/*.java src/main/java/com/scg/util/*.java
I am trying to
compile
all the java files in twopackages
. but I need to haveslf4j
in my classpath. but somehow I am not able to get it work.
Thanks - I tried to