error: package org.slf4j does not exist

August 2024 ยท 2 minute read

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;

5

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' } 
4

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"

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' } 

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJoa3FqYWl%2Fen2Onqmrp6JivaKvypqenmWfp7Ruv8ufa6NllKSytHnNqKtmnaiewLU%3D