我该如何解决java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory?

时间:2014-06-02 00:50:12

标签: java

我试图在我的IDE之外运行我的项目,并且我得到了这个java.lang.NoClassDefFoundError:org / slf4j / LoggerFactory

它在IDE中运行良好但是当尝试从批处理文件运行它时,它会加载应用程序面板并抛出此错误。

我已将所有库包含在批处理文件中,所有这些库都存在,并且它们与IDE内部使用的库相同。

java -cp bin;deps/InetAddressLocator.jar;deps/lombok.jar;deps/commons-collections4-4.0.jar;deps/mina-core-1.1.7.jar;deps/mysql.jar;deps/slf4j-api-1.6.1;deps/slf4j-simple-1.6.1.jar; game.engine.GameEngine true 0 0
pause

我该如何解决这个问题?

[02/06/2014 12:42:52 AM]: Exception in thread "main" 
[02/06/2014 12:42:52 AM]: java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
[02/06/2014 12:42:52 AM]:   at org.apache.mina.util.NamePreservingRunnable.<init>(NamePreservingRunnable.java:32)
[02/06/2014 12:42:52 AM]:   at org.apache.mina.transport.socket.nio.SocketAcceptor.startupWorker(SocketAcceptor.java:165)
[02/06/2014 12:42:52 AM]:   at org.apache.mina.transport.socket.nio.SocketAcceptor.bind(SocketAcceptor.java:141)
[02/06/2014 12:42:52 AM]:   at game.engine.GameEngine.main(GameEngine.java:125)
[02/06/2014 12:42:52 AM]: Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
[02/06/2014 12:42:52 AM]:   at java.net.URLClassLoader$1.run(Unknown Source)
[02/06/2014 12:42:52 AM]:   at java.net.URLClassLoader$1.run(Unknown Source)
[02/06/2014 12:42:52 AM]:   at java.security.AccessController.doPrivileged(Native Method)
[02/06/2014 12:42:52 AM]:   at java.net.URLClassLoader.findClass(Unknown Source)
[02/06/2014 12:42:52 AM]:   at java.lang.ClassLoader.loadClass(Unknown Source)
[02/06/2014 12:42:52 AM]:   at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
[02/06/2014 12:42:52 AM]:   at java.lang.ClassLoader.loadClass(Unknown Source)
[02/06/2014 12:42:52 AM]:   ... 4 more

2 个答案:

答案 0 :(得分:2)

java -cp bin;deps/InetAddressLocator.jar;deps/lombok.jar;deps/commons-collections4-4.0.jar;deps/mina-core-1.1.7.jar;deps/mysql.jar;deps/slf4j-api-1.6.1;deps/slf4j-simple-1.6.1.jar; game.engine.GameEngine true 0 0

slf4j-api-1.6.1正在扼杀&#34; .jar&#34;在末尾。它应该是&#34; slf4j-api-1.6.1.jar&#34;

答案 1 :(得分:0)

我认为,最好与Manifest Files合作。