10

I am trying to execute the following code:

import com.xuggle.mediatool.IMediaReader;
import com.xuggle.mediatool.IMediaWriter;
import com.xuggle.mediatool.ToolFactory;
public class vidcon {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        IMediaReader reader = ToolFactory.makeReader("test.m4v");
        IMediaWriter writer = ToolFactory.makeWriter("out.flv");

        reader.addListener(writer);
        while(reader.readPacket() == null)
            ;
    }
}

But it is is giving me this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    at com.xuggle.ferry.JNILibrary.<clinit>(JNILibrary.java:42)
    at com.xuggle.ferry.FerryJNI.<clinit>(FerryJNI.java:14)
    at com.xuggle.ferry.Ferry.<clinit>(Ferry.java:25)
    at com.xuggle.xuggler.XugglerJNI.<clinit>(XugglerJNI.java:19)
    at com.xuggle.xuggler.IContainer.<clinit>(IContainer.java:1622)
    at com.xuggle.mediatool.MediaReader.<init>(MediaReader.java:137)
    at com.xuggle.mediatool.ToolFactory.makeReader(ToolFactory.java:77)
    at vidcon.main(vidcon.java:11)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 8 more

I have added SLF4J to my referenced libraries, but have no idea why this is not working.

Running on WIN 7, tried in eclipse and netbeans

Any idea?

Kenster
  • 23,465
  • 21
  • 80
  • 106
1321941
  • 2,139
  • 5
  • 26
  • 49
  • Possible duplicate of [Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory](https://stackoverflow.com/questions/36377461/caused-by-java-lang-classnotfoundexception-org-slf4j-loggerfactory) – jediz May 24 '17 at 10:05

6 Answers6

34

Download SLF4J and put the slf4j-api-1.7.2.jar file onto your class path.

Robert Pes
  • 356
  • 3
  • 2
  • 3
    I too have the same problem. I downloaded the SLF4J but I can't understand what you mean by the class path. I placed the slf4j-api-1.7.2.jar file in the directory where I have my class file of the java file, but it is still having the same problem. – shamila Jul 16 '16 at 11:29
5

The following combination of jars is working for me:

log4j-1.2.16.jar
slf4j-api-1.7.6.jar
slf4j-simple-1.7.6.jar
xuggle-xuggler-5.4.jar

Chris Laplante
  • 29,338
  • 17
  • 103
  • 134
Arun
  • 1,011
  • 11
  • 13
3

Cause Could be un-availability of dependency jars or version conflicts.

The following jars combination worked fine for me:

xuggle-xuggler-5.4.jar
slf4j-api-1.6.4.jar
logback-core-1.0.0.jar
logback-classic-1.0.0.jar

AVA
  • 2,474
  • 2
  • 26
  • 41
2

you might be added the apache-log4j-2.7-bin jars. Just Remove all those Jars and keep only

log4j-1.2.16.jar
slf4j-api-1.7.6.jar
slf4j-simple-1.7.6.jar
xuggle-xuggler-5.4.jar
slfan
  • 8,950
  • 115
  • 65
  • 78
priya
  • 21
  • 3
1

Download SLF4J and put the slf4j-api-1.7.25.jar, slf4j-simple-1.7.25.jar files into application class path.

This will help to resolve this exception along with following exception SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".

0

Check your configuration file (.xml file). The first line in this must start with the declaration of XML version and encoding.

Otherwise, you will get the same error util unless you have included all the required .jar files.

CertainPerformance
  • 356,069
  • 52
  • 309
  • 320