Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: package org.slf4j does not exist

I am attempting to create a program in Java using Netbeans. I am attempting to use org.slf4j. I think I have placed the sufficient amount of slf4j jar files in my CLASS PATH. I have placed slf4j-api, slf4j-jcl, slf4j-jdk14, slf4j-nop and slf4j-simple in my class path.

My question is: Am i placing the wrong jar files in my class path, the Zip file for the slf4j folder included a large amount of jar files. Why are there so many executable jar files included for SLF4J.

Ultimately, the program needs to compare 2 pdf files at a time and spit out an error message if the files are different. Would anyone know if there is anything out there that I can include so I don't have to deal with this SLF4J package. Below is where I am attempting to run the package.

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

like image 277
Vutana Avatar asked Jan 11 '18 19:01

Vutana


3 Answers

Set Dependencies as follows.

In Maven

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>version number</version>
</dependency>

In Gradle

dependencies {
   compile group: 'org.slf4j', name: 'slf4j-api', version: 'version number'
}
like image 66
Pramuditha Avatar answered Nov 09 '22 19:11

Pramuditha


In Gradle add the following dependencies:

implementation 'org.slf4j:slf4j-api:1.7.28'
implementation 'org.slf4j:slf4j-simple:1.7.28' 

The last one dependency needs to be added to Resolve "Failed to load class org.slf4j.impl.StaticLoggerBinder"

like image 4
AlexPes Avatar answered Nov 09 '22 20:11

AlexPes


In build.gladle ( the second one ) look at dependencies and add this line:

dependencies {
   ...
   implementation 'org.apache.directory.studio:org.slf4j.api:1.7.2'
}
like image 3
Mike Zriel Avatar answered Nov 09 '22 21:11

Mike Zriel