Java:线程主 java.lang.NoClassDefFoundError 中的异常
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2845720/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java: Exception in thread main java.lang.NoClassDefFoundError
提问by cath
I am trying to get the Red5 Flash Media Server working on my computer. I have installed it, but when I run the server I get this error:-
我正在尝试让 Red5 Flash Media Server 在我的计算机上运行。我已经安装了它,但是当我运行服务器时出现此错误:-
Exception in thread "main" java.lang.NoClassDefFoundError: org/red5/server/Bootstrap
Caused by: java.lang.ClassNotFoundException: org.red5.server.Bootstrap
at java.net.URLClassLoader.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: org.red5.server.Bootstrap. Program will exit.
I came across this link where someone had the same issue: http://trac.red5.org/ticket/762
我遇到了有人遇到同样问题的链接:http: //trac.red5.org/ticket/762
It looks like they ran the following command:
看起来他们运行了以下命令:
export CLASSPATH=3D$RED5_HOME/lib/slf4j-api-1.5.10.jar:$RED5_HOME/lib/logback- core-0.9.18.jar:$RED5_HOME/lib/logback-classic-0.9.18.jar
I have red5 installed in /usr/share/red5, so I ran this:
我在 /usr/share/red5 中安装了 red5,所以我运行了这个:
export CLASSPATH=3D$/usr/share/red5/lib/slf4j-api-1.5.10.jar:$/usr/share/red5/lib/logback-core-0.9.18.jar:$/usr/share/red5/lib/logback-classic-0.9.18.jar
Yet despite all this I am still seeing the same error message.
尽管如此,我仍然看到相同的错误消息。
回答by Thanit
I used to have the same problem like "java.lang.ClassNotFoundException: org.red5.server.Bootstrap"after I builded a new red5 server from the trunk to 'dist' directory
我曾经"java.lang.ClassNotFoundException: org.red5.server.Bootstrap"遇到过同样的问题,就像我从主干到“dist”目录构建了一个新的 red5 服务器之后一样
just point RED5_HOME environment variable to that "dist"location.
只需将 RED5_HOME 环境变量指向该"dist"位置。
回答by Gaurav Vaish
The correct class path is:
正确的类路径是:
export CLASSPATH=/usr/share/red5/lib/slf4j-api-1.5.10.jar:/usr/share/red5/lib/logback-core-0.9.18.jar:/usr/share/red5/lib/logback-classic-0.9.18.jar
Notice:
注意:
- No 3D after
=sign - No
$before/usranywhere
=签名后没有 3D$在/usr任何地方之前都没有
回答by S-K'
You need to ensure your red5.sh has the correct permissions:
您需要确保您的 red5.sh 具有正确的权限:
chmod 755 red5.sh
The java AccessController is failing, thus the class is not being found.
java AccessController 失败,因此找不到该类。
回答by Triquetra
You did not build it from source after svn checkout. Just type ant after checkout :).
您没有在 svn checkout 后从源代码构建它。结帐后只需键入 ant :)。
回答by Paul Gregtheitroade
The red5 bootstrap class is in the boot.jar and this is the only jar that needs to be on the classpath when starting red5.
red5 引导程序类位于 boot.jar 中,这是启动 red5 时需要在类路径上的唯一 jar。
回答by duffymo
This might be incorrect:
这可能是不正确的:
export CLASSPATH=3D$/usr/share/red5/lib/slf4j-api-1.5.10.jar:$/usr/share/red5/lib/logback-core-0.9.18.jar:$/usr/share/red5/lib/logback-classic-0.9.18.jar
I think it should be:
我觉得应该是:
export CLASSPATH=/usr/share/red5/lib/slf4j-api-1.5.10.jar:/usr/share/red5/lib/logback-core-0.9.18.jar:/usr/share/red5/lib/logback-classic-0.9.18.jar
If that doesn't work, then the server is ignoring the CLASSPATH environment variable. Java EE app servers don't use it. Which server software are you using as the listener?
如果这不起作用,则服务器将忽略 CLASSPATH 环境变量。Java EE 应用服务器不使用它。您使用哪种服务器软件作为侦听器?

