开发者

Running Java Application NoClassDefFoundError

When I run my program from terminal by executing the command java rmiserver.LightBulbServer.class I'm getting NoClassDefFoundError :

Exception in thread "main" java.lang.NoClassDefFoundError: rmiserver/LightBulbSe
rver/class
Caused by: java.lang.ClassNotFoundException: rmiserver.LightBulbServer.class
        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.开发者_StackOverflowlang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: rmiserver.LightBulbServer.class.  Program will ex
it.


You are most likely running the application like this:

java rmiserver.LightBulbServer.class

You shouldn't add the .class extension when running your program; use only the name of the class:

java rmiserver.LightBulbServer


You're running the command:

java rmiserver.LightBulbServer.class

when you should be running

java rmiserver.LightBulbServer


You need to set some variables before Java can do anything on a system. This is why some people create batch files to get their Java programs running without modifying system variables.

But this usually happens because you didn't set the CLASSPATH.

For example, here is something that may or may not work:

set JAVA_HOME=C:\jdk1.5.0_06
set PATH=C:\jdk1.5.0_06\bin;C:\Windows;C:\Windows\System32
set CLASSPATH=.

java -jar myprogram.jar

Or try this command:

java -jar myprogram.jar -classpath .
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜